I'm using the  go-kit/kit/log 
(https://pkg.go.dev/github.com/go-kit/kit/log?tab=doc#Logger) abstraction:

    Log(keyvals ...interface{}) error

This can be set in my library, and uses with logfmt, if given.

[email protected] a következőt írta (2020. augusztus 3., hétfő, 18:33:11 
UTC+2):

> 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 [email protected] 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8bd69f3d-ed56-416e-8362-6d5f5d599009n%40googlegroups.com.

Reply via email to