mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
smtp: Use zerolog hooks for warns/errors expvars #90
This commit is contained in:
15
pkg/server/smtp/loghook.go
Normal file
15
pkg/server/smtp/loghook.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package smtp
|
||||
|
||||
import "github.com/rs/zerolog"
|
||||
|
||||
type logHook struct{}
|
||||
|
||||
// Run implements a zerolog hook that updates the SMTP warning/error expvars.
|
||||
func (h logHook) Run(e *zerolog.Event, level zerolog.Level, msg string) {
|
||||
switch level {
|
||||
case zerolog.WarnLevel:
|
||||
expWarnsTotal.Add(1)
|
||||
case zerolog.ErrorLevel:
|
||||
expErrorsTotal.Add(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user