Closed greenhat616 closed 1 year ago
Indeed, it'd be quite useful if zap
could be introduced as logger instead of using the built-in log
.
All the log calls are adjustable: you can write your own middleware for logging incoming requests with the logger package you like. There is also a Bot.OnError
field to override the error-handler.
Despite Go's poor design in not providing a standard Logger interface, we can still achieve a unified Logger instance by customizing the Logger interface. For example, I prefer using JSON logs for easy log collection.
Example
Later on, you only need to provide a Logger option when creating the robot (we can implement the Logger interface you require), and you can provide a default logger implementation at creation. I believe such changes are not very invasive.