New creates a root logger with given output writer. If the output writer implements the LevelWriter interface, the WriteLevel method will be called instead of the Write one. Each logging operation makes a single call to the Writer's Write method. There is no guarantee on access serialization to the
(w io.Writer)
| 244 | // guarantee on access serialization to the Writer. If your Writer is not thread safe, |
| 245 | // you may consider using sync wrapper. |
| 246 | func New(w io.Writer) Logger { |
| 247 | if w == nil { |
| 248 | w = io.Discard |
| 249 | } |
| 250 | lw, ok := w.(LevelWriter) |
| 251 | if !ok { |
| 252 | lw = LevelWriterAdapter{w} |
| 253 | } |
| 254 | return Logger{w: lw, level: TraceLevel} |
| 255 | } |
| 256 | |
| 257 | // Nop returns a disabled logger for which all operation are no-op. |
| 258 | func Nop() Logger { |
no outgoing calls