Skip to content

Add logging options to config#22

Merged
srid merged 2 commits intohpcloud:masterfrom
GeertJohan:master
Feb 23, 2014
Merged

Add logging options to config#22
srid merged 2 commits intohpcloud:masterfrom
GeertJohan:master

Conversation

@GeertJohan
Copy link
Contributor

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 tail logs.

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 log package's default logger (Log.std) when it's nil.

I hope this code will be useful for anyone else out there 😄

@srid
Copy link
Contributor

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 DisableLogging and exclusively use Config.Logger - which if set to nil or tail.DEFAULT_LOGGER (the default; or a custom logger), makes the tail library log to it, else (if explicitly set to tail.NO_LOGGER) totally suppresses logging?

@GeertJohan
Copy link
Contributor Author

What would tail.NO_LOGGER be? an io.Writer to /dev/null ?

@srid
Copy link
Contributor

srid commented Feb 19, 2014

yes. perhaps:

NIL_LOGGER=log.New(ioutil.Discard, "", log.LstdFlags)
...
// suppress logging
tail.Config{Logger: tail.NIL_LOGGER ...

@GeertJohan
Copy link
Contributor Author

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
Copy link
Contributor Author

Done.
I also exposed DefaultLogger (used when Config.Logger == nil)

srid pushed a commit that referenced this pull request Feb 23, 2014
Add logging options to config
@srid srid merged commit 751a3ad into hpcloud:master Feb 23, 2014
srid pushed a commit that referenced this pull request Feb 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants