Skip to content

Commit

Permalink
add Error method wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
orouz committed Jan 22, 2025
1 parent a2d988f commit 095e256
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/resources/utils/clog/clog.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ func (l *Logger) Errorf(template string, args ...any) {
l.Logger.Errorf(template, args...)
}

func (l *Logger) Error(args ...any) {
// Downgrade context.Canceled errors to warning level
if hasErrorType(context.Canceled, args...) {
l.Warn(args...)
return
}
l.Logger.Error(args...)
}

func (l *Logger) Named(name string) *Logger {
return &Logger{l.Logger.Named(name)}
}

func (l *Logger) WithOptions(options ...logp.LogOption) *Logger {
return &Logger{l.Logger.WithOptions(options...)}
}

func (l *Logger) With(args ...any) *Logger {
return &Logger{l.Logger.With(args...)}
}
Expand Down

0 comments on commit 095e256

Please sign in to comment.