-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Hello Gophers, I read about Clean Architecture and I don't find anything regarding Logger which is sometime really nested in the code base. I really like https://github.com/uber-go/zap and even with a Logger interface I don't see how to keep things like the zap.String, zap.Int, etc. compatible with it. Is this a case where you have to compromise? Where you can compromise? Sometimes it is a reproach made to this type of architecture and the way people tend to stick to it too much, e.g., I can change the database but in fact it will probably never happen (but it will help for testing). Can it be the same with the Logger? Maybe I will create an interface with so much cohesion with Zap that it fact it is maybe better to assume that the project will use directly Zap?
I'd say it depends. If I write a package for others to use I usually don't include a logger at all and let the user decide what he wants to use. For any other project that needs logging I usually skip the interface to not have the struggle with finding one interface that fits all at least logrus and zap. We kinda agreed at the team to just use zap by now. One.thing i wanted to try tho is using sth like logr which provides an interface for the most commonly used loggers.
This is why we wrote https://github.com/go-logr/life - it's the interface you can pass around while leaving the choice of implementation up to the topmost app layer. We include some implementation choices (zapr being one, and funcr being among the simplest) but that's not really the goal.
Something like this can help https://github.com/facily-tech/go-core/blob/main/log/interface.go
This cracks me up: https://github.com/inconshreveable/log15 and I use log15 :)
For that reason I would advise to use any logging aggregators that have rich adapters and capabilities to add new ones, eg. something like this: https://github.com/InVisionApp/go-logger . Note that this particular project is now abandoned (serious mem leak I posted as PR was never merged; I use my custom, public fork for that reason) so it is worth to ask: does anyone know about anything more recent, active and maintained that implements similar concept?