logger: add log level aliases

This commit is contained in:
wpetit 2020-03-17 13:26:49 +01:00
parent bc82c8b59c
commit 60d9fde890
1 changed files with 10 additions and 1 deletions

View File

@ -25,6 +25,15 @@ var defaultLogger slog.Logger // nolint: gochecknoglobals
type Field = slog.Field
type Map = slog.Map
type Level = slog.Level
const (
LevelCritical Level = slog.LevelCritical
LevelError Level = slog.LevelError
LevelWarn Level = slog.LevelWarn
LevelInfo Level = slog.LevelInfo
LevelDebug Level = slog.LevelDebug
)
func init() { // nolint: gochecknoinits
defaultLogger = Make(FormatHuman, os.Stdout)
@ -87,6 +96,6 @@ func E(err error) Field {
return slog.Error(err)
}
func SetLevel(level slog.Level) {
func SetLevel(level Level) {
defaultLogger = defaultLogger.Leveled(level)
}