Closed suyash closed 7 years ago
This does not look like I am able to redirect speed's output but rather copy log messages to extra writer if I read it right. I would like to be able to redirect all speed's output to syslog when debug is turned on, so I can find it along with my app logs. More than that, I very much like structured logging and this is awesome thing to have (kudos). I would love to be able to redirect speed into journald along with my application logs including all the extra fields.
But overall, definitely good step foreward, two dependencies instead of one! Big up.
Edit: The reason why I want to get rid of stdout is indeed - daemon mode. It will be eventually closed anyway, the only proper way of logging for daemons is journald these days (or syslog on older platforms). And I am writing a tiny daemon app with your lovely library :-)
@lzap this allows you to specify the io.Writer
interfaces logs are written to. By default the array is set to just os.Stdout
. With this PR you would be able to make a call like speed.SetLogWriters([]io.Writer{})
to set the log writers to an empty array. io.Writer
seems to be a pretty easy abstraction, you can create any type with a Write
method and set it as a log destination.
@lzap I have added tests to demonstrate usage for the functions. Please feel free to add comments :)
@lzap ping
This adds a couple of functions,
speed.AddLogWriter(io.Writer)
andspeed.SetLogWriters(...io.Writer)
to allow clients to modify the writers logs are written to.@lzap @natoscott PTAL.