Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smtp: Use zerolog hooks for warns/errors expvars #90
- Loading branch information
Showing
3 changed files
with
39 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |