UpdateContext updates the internal logger's context. Caution: This method is not concurrency safe. Use the With method to create a child logger before modifying the context from concurrent goroutines.
(update func(c Context) Context)
| 294 | // Caution: This method is not concurrency safe. |
| 295 | // Use the With method to create a child logger before modifying the context from concurrent goroutines. |
| 296 | func (l *Logger) UpdateContext(update func(c Context) Context) { |
| 297 | if l.disabled() { |
| 298 | return |
| 299 | } |
| 300 | if cap(l.context) == 0 { |
| 301 | l.context = make([]byte, 0, 500) |
| 302 | } |
| 303 | if len(l.context) == 0 { |
| 304 | l.context = enc.AppendBeginMarker(l.context) |
| 305 | } |
| 306 | c := update(Context{*l}) |
| 307 | l.context = c.l.context |
| 308 | } |
| 309 | |
| 310 | // Level creates a child logger with the minimum accepted level set to level. |
| 311 | func (l Logger) Level(lvl Level) Logger { |