v0.1.10 trace log level added avoiding toggle
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
// Log level constants
|
||||
const (
|
||||
LevelTrace int64 = -8
|
||||
LevelDebug int64 = -4
|
||||
LevelInfo int64 = 0
|
||||
LevelWarn int64 = 4
|
||||
|
||||
@@ -319,6 +319,8 @@ func (f *Formatter) appendValue(dst []byte, v any, serializer *sanitizer.Seriali
|
||||
// LevelToString converts integer level values to string
|
||||
func LevelToString(level int64) string {
|
||||
switch level {
|
||||
case -8:
|
||||
return "TRACE"
|
||||
case -4:
|
||||
return "DEBUG"
|
||||
case 0:
|
||||
|
||||
+8
-1
@@ -6,6 +6,8 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/lixenwraith/log/formatter"
|
||||
)
|
||||
|
||||
// getTrace returns a function call trace string
|
||||
@@ -83,6 +85,8 @@ func parseKeyValue(arg string) (string, string, error) {
|
||||
// Level converts level string to numeric constant
|
||||
func Level(levelStr string) (int64, error) {
|
||||
switch strings.ToLower(strings.TrimSpace(levelStr)) {
|
||||
case "trace":
|
||||
return LevelTrace, nil
|
||||
case "debug":
|
||||
return LevelDebug, nil
|
||||
case "info":
|
||||
@@ -98,6 +102,9 @@ func Level(levelStr string) (int64, error) {
|
||||
case "sys":
|
||||
return LevelSys, nil
|
||||
default:
|
||||
return 0, fmtErrorf("invalid level string: '%s' (use debug, info, warn, error, proc, disk, sys)", levelStr)
|
||||
return 0, fmtErrorf("invalid level string: '%s' (use trace, debug, info, warn, error, proc, disk, sys)", levelStr)
|
||||
}
|
||||
}
|
||||
|
||||
// LevelToString renders a level constant as its display name
|
||||
func LevelToString(level int64) string { return formatter.LevelToString(level) }
|
||||
|
||||
Reference in New Issue
Block a user