Assume I am writing
a) Packages intended as libraries for applications, that incorporate packages that also log
b) Applications that incorporate packages that also log.
The incorporated packages will not in the majority case be mine.
What I'd like to do is use the same logging library.
Here's what I'd like to be able to do:
* Specify different log levels, and have these passed to syslog and/or filtered in program dependent on application config file / command line
* Find some way of filtering by package or file etc. as well, so if I turn debug logging on in foo, it doesn't turn debug logging on in baz, just because foo imports bar which imports baz; again this filtering would be controlled by an application config file / command line
Sadly the standard "log" package does not define and export an interface which it implements. Therefore there is no 'standard logger', and (as far as I can see) no way of intercepting logs done in imported packages (that themselves just 'import "log"'), other than log.SetOutput(), and post-processing the log output. That's relatively disgusting a if I want to filter the log lines by package, I now need to parse log strings. It would have been nice if the log implementation passed semantic data (e.g. stack frame, prefix, priority) to an intermediate LogWriter, which in turn wrote those to an IOWriter, but that's not the case either. As it is, I can't see much way of rescuing existing packages besides parsing their log output. Ideas?
That leaves the choice of how to implement logging in my libraries and application. There appear to be a hundred existing packages to 'help', but no standard, and again sadly no interface, so (given log statements end up dotted around the source code) no easy way of swapping between any two, making the decision permanent--ish. Are there any common solutions here? Or (better) emerging standards?
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/d/optout.