On Fri, Jul 8, 2016 at 6:29 AM,  <zgersh...@pivotal.io> 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.
>
> Walking down this path led me to these specific questions:
>
> 1. Does any one REALLY test whether their app logs specific log lines (when
> logging is not your the apps primary function)

It depends on the application, but very often, logging is just as
critical a piece of business functionality as writing records to a
database. So, yes.

> 2. Why isn't log.Logger just an interface instead of a struct (or why isn't
> there a LogWriter interface that specifies a few of the log packages
> multiple methods)

I view this as one of the mistakes in the standard library. If we
didn't have the compatibility guarantee, I suspect it would be fixed.

Following from the above two points, I think it is a mistake to use
stdlib package log for anything other than quick hacks or toy
projects. For long-lived business code, you should definitely be using
a structured logging package based around a logger interface. Plugging
the work of my contributors,
http://godoc.org/github.com/go-kit/kit/log is one such high-quality
package.


> 3. What has been the litmus test for when the stdlib will provide an
> interface (like io.Writer)
>
> --
> 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.

-- 
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