From 4c760a471e0d29a7adc11da55d042fef390c81cce0fcb6766d2ff5efa7060d86 Mon Sep 17 00:00:00 2001 From: Lixen Wraith Date: Sat, 1 Aug 2026 08:46:34 -0400 Subject: [PATCH] v0.1.10 trace log level added avoiding toggle --- constant.go | 1 + formatter/formatter.go | 2 ++ utility.go | 11 +++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/constant.go b/constant.go index 9ad4adc..1be13ff 100644 --- a/constant.go +++ b/constant.go @@ -9,6 +9,7 @@ import ( // Log level constants const ( + LevelTrace int64 = -8 LevelDebug int64 = -4 LevelInfo int64 = 0 LevelWarn int64 = 4 diff --git a/formatter/formatter.go b/formatter/formatter.go index ccaf3f9..c7ee0a2 100644 --- a/formatter/formatter.go +++ b/formatter/formatter.go @@ -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: diff --git a/utility.go b/utility.go index d559a14..a422c87 100644 --- a/utility.go +++ b/utility.go @@ -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) } -} \ No newline at end of file +} + +// LevelToString renders a level constant as its display name +func LevelToString(level int64) string { return formatter.LevelToString(level) }