-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I use logrus and I'm requested to to write info and debug log messages to stdout, and warning, errors fatals and panics to stderr.
Currently I see no straightforward solutions for this, as Logger
has only one Out
.
I was thinking about writing writer that parses log message and writes to Stdout
or Stderr
depending on it's level, but this could break when log formatter is changed.
So I changed my mind thinking about creating "/dev/null" Writer
, and
log.SetOutput(NullWriter{}) // Send all logs to nowhere by default
Then write hooks that write logs to stderr and stdout, and register them for appropriate levels. (Something like this)
Which lead me to the question why have both Out
setting and Hooks
? Hooks alone would be enough with default hook for stderr and possibility to delete and add another hooks. And if there was already hook for standart outputs, my task would be much simpler. (So this could be regarded as a feature request).
Or what would developer of this library do to solve this?