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

Adding With in logger to keep logging key/value pairs #578

Merged
merged 1 commit into from Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/log/log.go
Expand Up @@ -22,6 +22,7 @@ type Logger interface {
Info(msg string, args ...interface{})
Warn(msg string, args ...interface{})
Error(msg string, args ...interface{})
With(args ...interface{}) Logger
Level() Level
}

Expand Down Expand Up @@ -82,5 +83,12 @@ func (l *hclogWrapper) Level() Level {
return NoLevel
}

// With creates a sub-logger that will always have the given key/value pairs.
func (l *hclogWrapper) With(args ...interface{}) Logger {
return &hclogWrapper{
logger: l.logger.With(args...),
}
}

// DefaultLogger is the default logger.
var DefaultLogger = New()