Output duplicates the current logger and sets w as its output.
(w io.Writer)
| 261 | |
| 262 | // Output duplicates the current logger and sets w as its output. |
| 263 | func (l Logger) Output(w io.Writer) Logger { |
| 264 | l2 := New(w) |
| 265 | l2.level = l.level |
| 266 | l2.sampler = l.sampler |
| 267 | l2.stack = l.stack |
| 268 | if len(l.hooks) > 0 { |
| 269 | l2.hooks = append(l2.hooks, l.hooks...) |
| 270 | } |
| 271 | if l.context != nil { |
| 272 | l2.context = make([]byte, len(l.context), cap(l.context)) |
| 273 | copy(l2.context, l.context) |
| 274 | } |
| 275 | return l2 |
| 276 | } |
| 277 | |
| 278 | // With creates a child logger with the field added to its context. |
| 279 | func (l Logger) With() Context { |