-
Notifications
You must be signed in to change notification settings - Fork 11
/
levels.go
47 lines (38 loc) · 1.02 KB
/
levels.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package lecho
import (
"github.com/labstack/gommon/log"
"github.com/rs/zerolog"
)
var (
echoLevels = map[log.Lvl]zerolog.Level{
log.DEBUG: zerolog.DebugLevel,
log.INFO: zerolog.InfoLevel,
log.WARN: zerolog.WarnLevel,
log.ERROR: zerolog.ErrorLevel,
log.OFF: zerolog.NoLevel,
}
zeroLevels = map[zerolog.Level]log.Lvl{
zerolog.TraceLevel: log.DEBUG,
zerolog.DebugLevel: log.DEBUG,
zerolog.InfoLevel: log.INFO,
zerolog.WarnLevel: log.WARN,
zerolog.ErrorLevel: log.ERROR,
zerolog.NoLevel: log.OFF,
}
)
// MatchEchoLevel returns a zerolog level and echo level for a given echo level
func MatchEchoLevel(level log.Lvl) (zerolog.Level, log.Lvl) {
zlvl, found := echoLevels[level]
if found {
return zlvl, level
}
return zerolog.NoLevel, log.OFF
}
// MatchZeroLevel returns an echo level and zerolog level for a given zerolog level
func MatchZeroLevel(level zerolog.Level) (log.Lvl, zerolog.Level) {
elvl, found := zeroLevels[level]
if found {
return elvl, level
}
return log.OFF, zerolog.NoLevel
}