Stdlib creates a standard library logger from the given logger. All logs will be logged at the level set by the logger and the given ctx will be passed to the logger's Log method, thereby logging all fields and tracing info in the context. You can redirect the stdlib default logger with log.SetOut
(ctx context.Context, l Logger, level Level)
| 16 | // to the Writer on the logger returned by this function. |
| 17 | // See the example. |
| 18 | func Stdlib(ctx context.Context, l Logger, level Level) *log.Logger { |
| 19 | l.skip += 2 |
| 20 | |
| 21 | l = l.Named("stdlib") |
| 22 | |
| 23 | w := &stdlogWriter{ |
| 24 | ctx: ctx, |
| 25 | l: l, |
| 26 | level: level, |
| 27 | } |
| 28 | |
| 29 | return log.New(w, "", 0) |
| 30 | } |
| 31 | |
| 32 | type stdlogWriter struct { |
| 33 | ctx context.Context |