combineLoggers returns a combined logger for both higher & lower severity logs, or only one if the other is io.Discard. This uses io.Discard instead of io.MultiWriter when all loggers are set to io.Discard. Both this package and the standard log package have significant optimizations for io.Discard
(lower, higher io.Writer)
| 234 | // significant optimizations for io.Discard, which io.MultiWriter lacks (as of |
| 235 | // this writing). |
| 236 | func combineLoggers(lower, higher io.Writer) io.Writer { |
| 237 | if lower == io.Discard { |
| 238 | return higher |
| 239 | } |
| 240 | if higher == io.Discard { |
| 241 | return lower |
| 242 | } |
| 243 | return io.MultiWriter(lower, higher) |
| 244 | } |
| 245 | |
| 246 | // NewLoggerV2 creates a new LoggerV2 instance with the provided configuration. |
| 247 | // The infoW, warningW, and errorW writers are used to write log messages of |