Hi all, a huge disclaimer - I am not familiar with the design
decisions and internal details of anything that follows. They are
coming from the point of view of a consumer of the language and the
ecosystem and also someone trying to write about these things for an
audience.
Say I have an application - a HTTP server, where I initialize a
log.Logger as implemented by the standard library and then I inject
that into the handler functions where they call the Printf() or the
other methods to log stuff. Say I have also configured a middleware to
log data for every request, once again using the Printf() and family
functions.
Now, I want to implement some levelled and/or structured logging. So,
here's my expectation - I should just be able to update the initial
code and everything else should not be changed. Of course, in due
course of time, I will update those to take advantage of the actual
functionality offered by those libraries - levelled logging,
structured logging. But, initially, my code should just build and
work. Many years back, that's how I really found
https://github.com/sirupsen/logrus useful and exciting. However, some
more performant and recent packages don't seem to have that
compatibility as a goal. For example,
https://github.com/uber-go/zap
doesn't AFAICT implement the Printf() or other functions. However,
https://github.com/rs/zerolog does, which is great.
I imagine this possibly is due to the standard library not exporting
publicly available types for - logging handlers, formatters (encoders)
and such that third party packages have difficulty implementing these
in standard library compatible way?
To summarize, I would have really wanted a way to avoid my code
becoming tightly coupled with the logging library I am using but that
seems to be hard at this stage.
What does the community think?