-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Currently salt/log package tries to abstract Logrus and Zap into a common formatted-logger interface (i.e., Infof(msg string, args ...any), etc. ). While logrus is designed as a formatted-logger, uber/zap is specifically designed for efficient structured logging and this kind of abstraction nullifies the major benefit of it.
I propose we remove this abstraction altogether1 and assume direct usage of zap within salt and in ODPF applications that use salt. Benefits of doing this:
- All the benefits of structured logging (easy to parse logs, easy to search/filter by field values, easy to attach request context with each log, etc.)
- Not giving an abstracted formatted-logger will force us to always stick to structured logging.
- Assuming zap as the logger of choice allows us to provide certain useful utility abstractions. Few examples:
* A request-logging middleware inmuxpackage that automatically logs request info (method, path, client-ip, etc.) and response info (status, response time, etc.)
* A middleware for injecting request related context (req-id, current user id, the route info, etc.) intoreq.Context()so that every log in all the subsequent layers automatically add this to every log entry.
Footnotes
-
We can still have some utility functions if we need to (e.g., a helper to inject log context into
ctx). But attempting to abstract over logging functionality will not have justifiable benefits. ↩
bsushmith, h4rikris, rohilsurana and AkarshSatija
Metadata
Metadata
Assignees
Labels
No labels