andersfylling / andersfylling/deplog
Please consider simplifing it and adding support for structured logging.
- Lingua principale
- Go
- Stelle
- 3
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Commenting on this as we recently wanted to find some reasonable interface for logging parameter for some new golang library. I thought our findings might be useful for you as well (:
Definitely std Golang logger is not nice, and some simple interface is what would be useful, so great idea overall. The problem is that this area is not trivial. There might be no good standard that will fit all. And we might end up with https://xkcd.com/927/
**Looking quickly on your interface I can (personally) see two main problems:**
* It is too large. I doubt you need so many log levels. See this great blog post, on how log levels can be limited to only `Info` and `Debug`: https://dave.cheney.net/2015/11/05/lets-talk-about-logging
* [Blocker]: This interface blocks structured logging. If you think about larger applications or swarm of those, you *have* to have proper logging pipleline that will store, index and allow to browse and aggregate them. That's why the log line has to have some kind of structure that will be readable for software. Read more about it here: https://www.client9.com/structured-logging-in-golang/
See those two nice libraries that allow structured logging (and are quite popular):
* https://github.com/sirupsen/logrus (`WithFields`)
* https://github.com/go-kit/kit/tree/master/log (pure forced structure).
and many more.
Also why the whole `Routing` logic? Why not just struct that implements your interface in the way that makes sense for other third party logger? It would be more explicit and clean and less runtime errors. Also what if the 3rd party logger have just `Print` with totally different arguments? (e.g just args ...interface{}), you cannot use routes anyway.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.