Skip to content

Commit 3c3b4a3

Browse files
committed
Add ability to customize level values
1 parent 4de2fcc commit 3c3b4a3

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

globals.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,22 @@ var (
2727
// LevelFieldName is the field name used for the level field.
2828
LevelFieldName = "level"
2929

30-
// LevelFieldMarshalFunc allows customization of global level field marshaling
30+
// LevelTraceValue is the value used for the trace level field.
31+
LevelTraceValue = "trace"
32+
// LevelDebugValue is the value used for the debug level field.
33+
LevelDebugValue = "debug"
34+
// LevelInfoValue is the value used for the info level field.
35+
LevelInfoValue = "info"
36+
// LevelWarnValue is the value used for the warn level field.
37+
LevelWarnValue = "warn"
38+
// LevelErrorValue is the value used for the error level field.
39+
LevelErrorValue = "error"
40+
// LevelFatalValue is the value used for the fatal level field.
41+
LevelFatalValue = "fatal"
42+
// LevelPanicValue is the value used for the panic level field.
43+
LevelPanicValue = "panic"
44+
45+
// LevelFieldMarshalFunc allows customization of global level field marshaling.
3146
LevelFieldMarshalFunc = func(l Level) string {
3247
return l.String()
3348
}

log.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,19 @@ const (
134134
func (l Level) String() string {
135135
switch l {
136136
case TraceLevel:
137-
return "trace"
137+
return LevelTraceValue
138138
case DebugLevel:
139-
return "debug"
139+
return LevelDebugValue
140140
case InfoLevel:
141-
return "info"
141+
return LevelInfoValue
142142
case WarnLevel:
143-
return "warn"
143+
return LevelWarnValue
144144
case ErrorLevel:
145-
return "error"
145+
return LevelErrorValue
146146
case FatalLevel:
147-
return "fatal"
147+
return LevelFatalValue
148148
case PanicLevel:
149-
return "panic"
149+
return LevelPanicValue
150150
case Disabled:
151151
return "disabled"
152152
case NoLevel:

0 commit comments

Comments
 (0)