-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Description
This code is not designed well: https://github.com/gorilla/handlers/blob/master/recovery.go#L49
func RecoveryLogger(logger *log.Logger) RecoveryOption {
return func(h http.Handler) {
r := h.(*recoveryHandler)
r.logger = logger
}
}
You should avoid accepting structs and instead try to accept interfaces whenever possible. In this particular case, since you are only using the Println(...interface{}) method, you should create an interface for the input argument like this:
type Logger interface {
Println(v ...interface{}}
}
This would allow users to pass a custom structured logger (e.g. Logrus), which might have some other fields/tags like environment, host, user, application etc. Unstructured logs in a highly distributed environment are totally useless.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels