Add ability to customize level values
This commit is contained in:
parent
4de2fcc128
commit
3c3b4a354e
17
globals.go
17
globals.go
|
@ -27,7 +27,22 @@ var (
|
|||
// LevelFieldName is the field name used for the level field.
|
||||
LevelFieldName = "level"
|
||||
|
||||
// LevelFieldMarshalFunc allows customization of global level field marshaling
|
||||
// LevelTraceValue is the value used for the trace level field.
|
||||
LevelTraceValue = "trace"
|
||||
// LevelDebugValue is the value used for the debug level field.
|
||||
LevelDebugValue = "debug"
|
||||
// LevelInfoValue is the value used for the info level field.
|
||||
LevelInfoValue = "info"
|
||||
// LevelWarnValue is the value used for the warn level field.
|
||||
LevelWarnValue = "warn"
|
||||
// LevelErrorValue is the value used for the error level field.
|
||||
LevelErrorValue = "error"
|
||||
// LevelFatalValue is the value used for the fatal level field.
|
||||
LevelFatalValue = "fatal"
|
||||
// LevelPanicValue is the value used for the panic level field.
|
||||
LevelPanicValue = "panic"
|
||||
|
||||
// LevelFieldMarshalFunc allows customization of global level field marshaling.
|
||||
LevelFieldMarshalFunc = func(l Level) string {
|
||||
return l.String()
|
||||
}
|
||||
|
|
14
log.go
14
log.go
|
@ -134,19 +134,19 @@ const (
|
|||
func (l Level) String() string {
|
||||
switch l {
|
||||
case TraceLevel:
|
||||
return "trace"
|
||||
return LevelTraceValue
|
||||
case DebugLevel:
|
||||
return "debug"
|
||||
return LevelDebugValue
|
||||
case InfoLevel:
|
||||
return "info"
|
||||
return LevelInfoValue
|
||||
case WarnLevel:
|
||||
return "warn"
|
||||
return LevelWarnValue
|
||||
case ErrorLevel:
|
||||
return "error"
|
||||
return LevelErrorValue
|
||||
case FatalLevel:
|
||||
return "fatal"
|
||||
return LevelFatalValue
|
||||
case PanicLevel:
|
||||
return "panic"
|
||||
return LevelPanicValue
|
||||
case Disabled:
|
||||
return "disabled"
|
||||
case NoLevel:
|
||||
|
|
Loading…
Reference in New Issue