Skip to content

Commit

Permalink
generate a warning when a default logger is created
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Jan 18, 2025
1 parent a840838 commit 74c3d8a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/logger/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package logger

import (
"context"

"go.uber.org/zap"
)

Expand Down Expand Up @@ -77,7 +78,9 @@ func (l *Logger) IsDebugEnabled() bool {
func GetLoggerFromContext(ctx context.Context) *Logger {
logger, ok := ctx.Value(loggerKey).(*Logger)
if !ok {
return NewLogger()
newLogger := NewLogger()
newLogger.Warnf("Logger had to be created without configuration because the context was missing")
return newLogger
}
return logger
}
Expand Down

0 comments on commit 74c3d8a

Please sign in to comment.