Uh oh!
There was an error while loading. Please reload this page.
Add logging options to config - #22
Conversation
srid
commented
Feb 19, 2014
i understand the intent to suppress logging from a library, however do we really want to add two more config options? i.e., why not avoid |
GeertJohan
commented
Feb 19, 2014
What would tail.NO_LOGGER be? an io.Writer to /dev/null ? |
srid
commented
Feb 19, 2014
yes. perhaps: NIL_LOGGER=log.New(ioutil.Discard, "", log.LstdFlags)
...// suppress logging
tail.Config{Logger: tail.NIL_LOGGER... |
GeertJohan
commented
Feb 22, 2014
It feels a bit like using cpu-time for nothing to log to ioutil.Discard. But I can see the simplicity it adds to the configuration of tail. Also, tail doesn't log that much, so there's not that much wasted cputime.. Working on a patch now. |
GeertJohan
commented
Feb 22, 2014
Done. |
The library generates logging output when files are closed or recreated. I didn't want to display this to the user of my program so I added extra options to modify the way
taillogs.There's
Config.Logger, allowing you to set your own Logger (using logfile, or other prefix or flags).And there's
Config.DisableLogging, which disables logging all together..This doesn't change anything for existing users, as Config.Logger is set to the
logpackage's default logger (Log.std) when it's nil.I hope this code will be useful for anyone else out there 😄