Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return from log functions that print err and message instead of print… #492

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (l *Logger) ZDeubg() *zerolog.Event {
func (l *Logger) Debug(msg string, err ...error) {
if len(err) == 1 {
zlog.Debug().Err(err[0]).Msg(msg)
return
}
zlog.Debug().Msg(msg)
}
Expand All @@ -38,6 +39,7 @@ func (l *Logger) ZInfo() *zerolog.Event {
func (l *Logger) Info(msg string, err ...error) {
if len(err) == 1 {
zlog.Info().Err(err[0]).Msg(msg)
return
}
zlog.Info().Msg(msg)
}
Expand All @@ -49,6 +51,7 @@ func (l *Logger) Infof(msg string, args ...interface{}) {
func (l *Logger) Warn(msg string, err ...error) {
if len(err) == 1 {
zlog.Warn().Err(err[0]).Msg(msg)
return
}
zlog.Warn().Msg(msg)
}
Expand All @@ -60,6 +63,7 @@ func (l *Logger) Warnf(msg string, args ...interface{}) {
func (l *Logger) Error(msg string, err ...error) {
if len(err) == 1 {
zlog.Error().Err(err[0]).Msg(msg)
return
}
zlog.Error().Msg(msg)
}
Expand All @@ -71,6 +75,7 @@ func (l *Logger) Errorf(msg string, args ...interface{}) {
func (l *Logger) Fatal(msg string, err ...error) {
if len(err) == 1 {
zlog.Fatal().Err(err[0]).Msg(msg)
return
}
zlog.Fatal().Msg(msg)
}
Expand All @@ -82,6 +87,7 @@ func (l *Logger) Fatalf(msg string, args ...interface{}) {
func (l *Logger) Panic(msg string, err ...error) {
if len(err) == 1 {
zlog.Panic().Err(err[0]).Msg(msg)
return
}
zlog.Panic().Msg(msg)
}
Expand Down
Loading