Let's think about where we want to instantiate our logger and then where we want to use it and log messages. This is important because we need to make sure that the logger is available to all the places in the code that need to log messages. A trivial approach is to just add a logger parameter to all our interfaces and propagate the logger in this way. However, this is very disruptive and will violate our clean object model. Logging is really an implementation and operational detail. Ideally, it should not appear in our object model types or interfaces. Also, it is a Go-kit type and, so far, we've managed to keep our object model and even our domain packages totally oblivious to the fact that they are wrapped by ...
Using a logging middleware
Get Hands-On Microservices with Kubernetes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.