The Go Logging Facade (golf) is a thin abstraction over various structured loggers.
golf adheres to semantic versioning. Any breaking changes before version
1.0 or between major versions are listed under Breaking
Changes.
This package strives to provide a facade over as many loggers as
possible. This allows to keep your code independent from those loggers
and to exchange them as needed. By using the golf.Logger interface
library code can accept an optional logger which allows it to use
whatever logger the calling application uses.
Additionally using different loggers during test execution can be handy, for example if the fact that a message was logged, or its contents need to be asserted.
Versions before 0.3.0 used to define a Logger interfaces that was
identical to go-kit's
Logger interface.
However, I found that calling code almost never checks the error
returned by Log. In most cases it is just ignored. Usually this goes
along with configuring errcheck
to ignore the Logger interface.
In most cases code calling the Log method should not be concerned by
an error in the logging library. Ideally the operation should continue
to be executed. If it is really necessary to handle an error that
occurred during logging, golf provides an
Error method.
This method allows to access the last error that occurred during
logging, if the underlying logger adapter supports it.
- stdlib: included in main repository
- zap: https://github.com/fhofherr/golf-zap
The following lists all breaking changes between versions.
- Replaced
golf.NewStdlibwithgolfstdlib.NewLogger. Made theformatterargument ofNewLoggeroptional. - Moved
golf.Formattertogolfstdlib.Formatter - Moved
golf.PlainTextFormattertogolfstdlib.PlainTextFormatter - Moved
golf.JSONFormattertogolfstdlib.JSONFormatter
- Moved
log.Loggertogolf.Logger - Moved
log.Logtogolf.Log - Moved
log.NewStdlibtogolf.NewStdlib - Moved
log.Formattertogolf.Formatter - Moved
log.PlainTextFormattertogolf.PlainTextFormatter - Moved
log.JSONFormattertogolf.JSONFormatter - Removed remaining
logpackage
Copyright © 2021 Ferdinand Hofherr
Distributed under the MIT License.