diff options
Diffstat (limited to 'internal/log')
| -rw-r--r-- | internal/log/log.go | 5 | ||||
| -rw-r--r-- | internal/log/log_test.go | 6 |
2 files changed, 4 insertions, 7 deletions
diff --git a/internal/log/log.go b/internal/log/log.go index 60c9371a..8238cae2 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -67,7 +67,7 @@ func SetLevel(v string) { currentLevel = toLevel(v) } -func getLevel() Severity { +func GetLevel() Severity { mu.Lock() defer mu.Unlock() return currentLevel @@ -87,7 +87,6 @@ func (stdlibLogger) Log(ctx context.Context, s Severity, payload any) { extra = " (" + strings.Join(extras, ", ") + ")" } log.Printf("%s%s: %+v", s, extra, payload) - } func (stdlibLogger) Flush() {} @@ -151,7 +150,7 @@ func Fatal(ctx context.Context, arg any) { } func doLog(ctx context.Context, s Severity, payload any) { - if getLevel() > s { + if GetLevel() > s { return } mu.Lock() diff --git a/internal/log/log_test.go b/internal/log/log_test.go index 791bd775..d2ef9d53 100644 --- a/internal/log/log_test.go +++ b/internal/log/log_test.go @@ -19,7 +19,7 @@ const ( // Do not run in parallel. It overrides currentLevel. func TestSetLogLevel(t *testing.T) { - oldLevel := getLevel() + oldLevel := GetLevel() defer func() { currentLevel = oldLevel }() tests := []struct { @@ -38,7 +38,7 @@ func TestSetLogLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { SetLevel(test.newLevel) - gotLevel := getLevel() + gotLevel := GetLevel() if test.wantLevel != gotLevel { t.Errorf("Error: want=%s, got=%s", test.wantLevel, gotLevel) } @@ -69,7 +69,6 @@ func TestLogLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - test.logFunc(context.Background(), test.logMsg) logs := logger.(*mockLogger).logs got := strings.Contains(logs, test.logMsg) @@ -101,7 +100,6 @@ func TestDefaultLogLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - test.logFunc(context.Background(), test.logMsg) logs := logger.(*mockLogger).logs |
