MCPcopy Index your code
hub / github.com/redpanda-data/console / Example_withContext

Function Example_withContext

backend/pkg/logger/example_test.go:54–69  ·  view source on GitHub ↗

Example_withContext demonstrates context-aware logging using structured attributes.

()

Source from the content-addressed store, hash-verified

52
53// Example_withContext demonstrates context-aware logging using structured attributes.
54func Example_withContext() {
55 // Create logger
56 log := logger.NewSlogLogger(
57 logger.WithLevel(slog.LevelInfo),
58 )
59
60 // Create context and log with structured attributes
61 ctx := context.Background()
62
63 // Log message with context-related attributes
64 log.InfoContext(ctx, "user action performed",
65 slog.String("action", "update_profile"),
66 slog.String("request_id", "req-123"),
67 slog.String("user_id", "user-456"),
68 )
69}
70
71// Example_enterprise demonstrates how to add custom handlers for enterprise features.
72func Example_enterprise() {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…