Not sure if this is what you are looking for, but 
https://github.com/go-logr/logr seems to address log abstraction.

On Friday, July 31, 2020 at 3:05:03 AM UTC+2 fai...@google.com wrote:

> I have a library that is used by cross platform binaries running in corp. 
> Some of these binaries don't necessary run google.Init.
>
> My library is using base/go/log package but this doesn't work when 
> google.Init isn't called. It prints to stderr with a message "ERROR: 
> logging before google.Init". This crashes windows services which crash if 
> there is anything written to stdout or stderr.
>
> My first thought was to have the callers provide a standard log.Logger 
> instance which could be used instead of the base/go/log package. Most 
> binaries could use the base/go/log NewStandardLogger function to get this. 
> While windows services could have a logger instance which just writes out 
> to ioutil.Discard. The downside is I will need multiple *log.Logger 
> instances for different log levels which doesn't seem great.  
>
> Is there a better way to do this? 
>
>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/48b1f7ab-949d-4aa3-81e3-c92a784b11can%40googlegroups.com.

Reply via email to