Skip to content

Commit

Permalink
feat(worker): add service worker to log output
Browse files Browse the repository at this point in the history
  • Loading branch information
Zibbp committed Mar 20, 2024
1 parent 9c93341 commit 5cc4652
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Logger struct {

func (l *Logger) Debug(msg string, keyvals ...interface{}) {
if len(keyvals)%2 != 0 {
l.logger.Debug().Msgf(msg)
l.logger.Debug().Str("service", "worker").Msgf(msg)
return
}

Expand All @@ -42,12 +42,12 @@ func (l *Logger) Debug(msg string, keyvals ...interface{}) {
}
}

l.logger.Debug().Fields(fields).Msg(msg)
l.logger.Debug().Str("service", "worker").Fields(fields).Msg(msg)
}

func (l *Logger) Info(msg string, keyvals ...interface{}) {
if len(keyvals)%2 != 0 {
l.logger.Info().Msgf(msg)
l.logger.Info().Str("service", "worker").Msgf(msg)
return
}

Expand All @@ -58,12 +58,12 @@ func (l *Logger) Info(msg string, keyvals ...interface{}) {
}
}

l.logger.Info().Fields(fields).Msg(msg)
l.logger.Info().Str("service", "worker").Fields(fields).Msg(msg)
}

func (l *Logger) Warn(msg string, keyvals ...interface{}) {
if len(keyvals)%2 != 0 {
l.logger.Warn().Msgf(msg)
l.logger.Warn().Str("service", "worker").Msgf(msg)
return
}

Expand All @@ -74,7 +74,7 @@ func (l *Logger) Warn(msg string, keyvals ...interface{}) {
}
}

l.logger.Warn().Fields(fields).Msg(msg)
l.logger.Warn().Str("service", "worker").Fields(fields).Msg(msg)
}

func (l *Logger) Error(msg string, keyvals ...interface{}) {
Expand All @@ -90,7 +90,7 @@ func (l *Logger) Error(msg string, keyvals ...interface{}) {
}
}

l.logger.Error().Fields(fields).Msg(msg)
l.logger.Error().Str("service", "worker").Fields(fields).Msg(msg)
}

func main() {
Expand Down

0 comments on commit 5cc4652

Please sign in to comment.