diff options
-rw-r--r-- | src/gobang.go | 15 | ||||
-rw-r--r-- | tests/gobang.go | 4 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/gobang.go b/src/gobang.go index fab8392..f13fc80 100644 --- a/src/gobang.go +++ b/src/gobang.go @@ -48,8 +48,10 @@ type CopyResult struct { var ( level LogLevel = LevelInfo - emitMetric bool = true + emitMetric = true hostname string + + SourceInfoSkip = 3 ) @@ -117,7 +119,6 @@ func anyArr[S ~[]E, E any](arr S) []any { return ret } -const sourceInfoSkip = 4 func Debug(message string, type_ string, args ...any) { if level < LevelDebug { return @@ -127,7 +128,7 @@ func Debug(message string, type_ string, args ...any) { message, slices.Concat( anyArr(logArgs(type_)), - []any { sourceInfo(sourceInfoSkip) }, + []any { sourceInfo(SourceInfoSkip) }, args, )..., ) @@ -142,7 +143,7 @@ func Info(message string, type_ string, args ...any) { message, slices.Concat( anyArr(logArgs(type_)), - []any { sourceInfo(sourceInfoSkip) }, + []any { sourceInfo(SourceInfoSkip) }, args, )..., ) @@ -157,7 +158,7 @@ func Warning(message string, type_ string, args ...any) { message, slices.Concat( anyArr(logArgs(type_)), - []any { sourceInfo(sourceInfoSkip) }, + []any { sourceInfo(SourceInfoSkip) }, args, )..., ) @@ -172,7 +173,7 @@ func Error(message string, type_ string, args ...any) { message, slices.Concat( anyArr(logArgs(type_)), - []any { sourceInfo(sourceInfoSkip) }, + []any { sourceInfo(SourceInfoSkip) }, args, )..., ) @@ -192,7 +193,7 @@ func metric(type_ string, label string, args ...any) { "type", type_, "label", label, }, - []any { sourceInfo(sourceInfoSkip) }, + []any { sourceInfo(SourceInfoSkip) }, args, )..., ) diff --git a/tests/gobang.go b/tests/gobang.go index 7a88f28..518748e 100644 --- a/tests/gobang.go +++ b/tests/gobang.go @@ -640,6 +640,9 @@ func test_SetLoggerOutput() { savedLogger := slog.Default() Testing("the output JSON has data under \"src\"", func() { + saved := SourceInfoSkip + SourceInfoSkip = 3 + s := new(strings.Builder) SetLoggerOutput(s) Info("", "") @@ -670,6 +673,7 @@ func test_SetLoggerOutput() { AssertEqual(ok, true) _, ok = lineRaw.(float64) AssertEqual(ok, true) + SourceInfoSkip = saved }) Testing("the output JSON has data under \"info\"", func() { |