FromContext returns the Logger associated with ctx, or the default logger.
(ctx context.Context)
| 45 | |
| 46 | // FromContext returns the Logger associated with ctx, or the default logger. |
| 47 | func FromContext(ctx context.Context) *Logger { |
| 48 | if l, ok := ctx.Value(contextKey{}).(*Logger); ok { |
| 49 | return l |
| 50 | } |
| 51 | return wrapSlog(slog.Default().Handler(), LevelInfo) |
| 52 | } |
| 53 | |
| 54 | // NewContext returns a new context with the given logger. |
| 55 | func NewContext(ctx context.Context, logger *Logger) context.Context { |