With creates a child logger with the field added to its context.
()
| 277 | |
| 278 | // With creates a child logger with the field added to its context. |
| 279 | func (l Logger) With() Context { |
| 280 | context := l.context |
| 281 | l.context = make([]byte, 0, 500) |
| 282 | if context != nil { |
| 283 | l.context = append(l.context, context...) |
| 284 | } else { |
| 285 | // This is needed for AppendKey to not check len of input |
| 286 | // thus making it inlinable |
| 287 | l.context = enc.AppendBeginMarker(l.context) |
| 288 | } |
| 289 | return Context{l} |
| 290 | } |
| 291 | |
| 292 | // UpdateContext updates the internal logger's context. |
| 293 | // |