It would have been quite useful for the stdlib to define a logger 
interface, so that third party loggers would implement it and allow for 
easier switching between them

On Friday, July 8, 2016 at 11:34:01 AM UTC+3, Ian Davis wrote:
>
> On Fri, Jul 8, 2016, at 05:29 AM, zger...@pivotal.io <javascript:> wrote:
>
> Hey All,
>  
> Originally asked on twitter but a more long-form medium is required to 
> answer this question. I've recently been working on adding logging to a 
> library and have been replacing what was once a custom logging interface 
> with just *log.Logger. In so doing, I removed my ability to mock the logger 
> (if I choose) and that steered me towards not testing / test-driving any of 
> my logging output.
>
>  
> Your code should define an interface that includes the methods from 
> log.Logger that you want to use. Then you can pass a *log.Logger to it or a 
> mock for testing. Your code shouldn't care about the type it is using, just 
> whether it can call Printf or Fatalf methods.
>  
> -- Ian
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to