Details
-
Task
-
Resolution: Unresolved
-
Minor
-
None
Description
For logging we currently use the global Zap logger and manually add a prefix, for example:
zap.S().Infow("(Manager) Starting", "frequencies", config) |
The Zap devs consider this to be bad practice:
Why include package-global loggers?
Since so many other logging packages include a global logger, many applications aren't designed to accept loggers as explicit parameters. Changing function signatures is often a breaking change, so zap includes global loggers to simplify migration.
Avoid them where possible.
We may wish to consider moving to named, scoped loggers. For example, in the above example, Manager would have a logger *zap.SugaredLogger field, and the line would look like:
m.logger.Infow("Starting", "frequencies", config) |
Attachments
Issue Links
- is duplicated by
-
CMOS-29 Better take advantage of structured logging
- To Do