felice icon indicating copy to clipboard operation
felice copied to clipboard

Replace logger by logrus or equivalent

Open asdine opened this issue 6 years ago • 2 comments

In order to better control the behaviour of the logs and be able for example to send everything that was logged on Error level to Sentry, we need a library that supports log levels. The obvious choice would be Logrus because we already have ready to use hooks in our internal libraries and it's one of the most used logging library in the Go community.

asdine avatar Jan 10 '19 10:01 asdine

I'd strongly prefer using an interface rather than a tight binding - there are other compatible loggers (like apex/log) that provide different feature sets. Logrus compatibility is desirable, a hard binding to it less so.

tealeg avatar Jan 10 '19 10:01 tealeg

My concern with an interface is that it limits the possibilities and requires too much work. Logrus, Apex, Zerolog etc. use method chaining for building a single log line. Adding an interface to deal with that means in fact adding multiple big interfaces that will be painful to implement.

IMO customizing a logger means being able to:

  • select the log level
  • select the output (io.Writer)
  • add hooks

Also, it must output JSON.

We could simply select any logger that is capable of doing so and use it as is, I don't think it would handicap users in any way as long as they can customize the points above.

I'm just afraid that abstracting the logger would make us write something too big.

WDYT?

asdine avatar Jan 10 '19 11:01 asdine