From 6f0468b925872520880b69ad48e116b7bad81699 Mon Sep 17 00:00:00 2001 From: Daniele Ferru Date: Mon, 12 Dec 2022 15:28:47 +0100 Subject: [PATCH] adding With in logger interface/implementation --- backend/log/log.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/log/log.go b/backend/log/log.go index 9c9f03cfb..e23185a9b 100644 --- a/backend/log/log.go +++ b/backend/log/log.go @@ -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 } @@ -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()