Example_withContext demonstrates context-aware logging using structured attributes.
()
| 52 | |
| 53 | // Example_withContext demonstrates context-aware logging using structured attributes. |
| 54 | func 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. |
| 72 | func Example_enterprise() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…