diff --git a/go.mod b/go.mod index e8e0b6fe..b97a3f52 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect github.com/apache/cloudstack-go/v2 v2.15.0 github.com/cloudfoundry/bosh-cpi-go v0.0.0-20240106100135-d51a7b0a8542 - github.com/cloudfoundry/bosh-utils v0.0.424 + github.com/cloudfoundry/bosh-utils v0.0.425 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.31.0 github.com/prometheus/common v0.46.0 diff --git a/go.sum b/go.sum index 39249d83..1b2d1419 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/charlievieth/fs v0.0.3 h1:3lZQXTj4PbE81CVPwALSn+JoyCNXkZgORHN6h2XHGlg github.com/charlievieth/fs v0.0.3/go.mod h1:hD4sRzto1Hw8zCua76tNVKZxaeZZr1RiKftjAJQRLLo= github.com/cloudfoundry/bosh-cpi-go v0.0.0-20240106100135-d51a7b0a8542 h1:gWi/cBvh3rfVMSyyNR11+3B1TE9RyRXKvRtmQZE+lZ4= github.com/cloudfoundry/bosh-cpi-go v0.0.0-20240106100135-d51a7b0a8542/go.mod h1:Am5Q+CCMOR8jBa/D025oiPCyUaCYBRFD00pAiyVlqDc= -github.com/cloudfoundry/bosh-utils v0.0.424 h1:ap9QL5FURJvhO9JVjlSDwqJ5D2GaFKW8yAXoM6D6yTQ= -github.com/cloudfoundry/bosh-utils v0.0.424/go.mod h1:TJjvzOTmMvYyEvsuvieiLmrWqTP5pSklNHiTFIPIQO0= +github.com/cloudfoundry/bosh-utils v0.0.425 h1:bmiu2E+CQyXytREcogkcJsClV72fq/+C3L5Yjruo5vY= +github.com/cloudfoundry/bosh-utils v0.0.425/go.mod h1:TJjvzOTmMvYyEvsuvieiLmrWqTP5pSklNHiTFIPIQO0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/vendor/github.com/cloudfoundry/bosh-utils/logger/async.go b/vendor/github.com/cloudfoundry/bosh-utils/logger/async.go index d16a5ec4..ff01ed46 100644 --- a/vendor/github.com/cloudfoundry/bosh-utils/logger/async.go +++ b/vendor/github.com/cloudfoundry/bosh-utils/logger/async.go @@ -134,3 +134,7 @@ func (l *asyncLogger) ToggleForcedDebug() { func (l *asyncLogger) UseRFC3339Timestamps() { l.log.UseRFC3339Timestamps() } + +func (l *asyncLogger) UseTags(tags []LogTag) { + l.log.UseTags(tags) +} diff --git a/vendor/github.com/cloudfoundry/bosh-utils/logger/logger.go b/vendor/github.com/cloudfoundry/bosh-utils/logger/logger.go index 06a1d110..eaaed0c5 100644 --- a/vendor/github.com/cloudfoundry/bosh-utils/logger/logger.go +++ b/vendor/github.com/cloudfoundry/bosh-utils/logger/logger.go @@ -52,8 +52,8 @@ func AsString(level LogLevel) string { return "DEBUG" } -//to update cd logger && go run github.com/maxbrunsfeld/counterfeiter -generate -//counterfeiter:generate . Logger +// to update cd logger && go run github.com/maxbrunsfeld/counterfeiter -generate +// counterfeiter:generate . Logger type Logger interface { Debug(tag, msg string, args ...interface{}) DebugWithDetails(tag, msg string, args ...interface{}) @@ -64,6 +64,7 @@ type Logger interface { HandlePanic(tag string) ToggleForcedDebug() UseRFC3339Timestamps() + UseTags(tags []LogTag) Flush() error FlushTimeout(time.Duration) error } @@ -74,6 +75,12 @@ type logger struct { forcedDebug bool loggerMu sync.Mutex timestampFormat string + tags []LogTag +} + +type LogTag struct { + Name string `json:"name"` + LogLevel LogLevel `json:"log_level"` } func New(level LogLevel, out *log.Logger) Logger { @@ -100,11 +107,15 @@ func (l *logger) UseRFC3339Timestamps() { l.timestampFormat = rfc3339TimeFormat } +func (l *logger) UseTags(tags []LogTag) { + l.tags = tags +} + func (l *logger) Flush() error { return nil } func (l *logger) FlushTimeout(_ time.Duration) error { return nil } func (l *logger) Debug(tag, msg string, args ...interface{}) { - if l.level > LevelDebug && !l.forcedDebug { + if l.getLogLevel(tag) > LevelDebug && !l.forcedDebug { return } @@ -120,7 +131,7 @@ func (l *logger) DebugWithDetails(tag, msg string, args ...interface{}) { } func (l *logger) Info(tag, msg string, args ...interface{}) { - if l.level > LevelInfo && !l.forcedDebug { + if l.getLogLevel(tag) > LevelInfo && !l.forcedDebug { return } @@ -129,7 +140,7 @@ func (l *logger) Info(tag, msg string, args ...interface{}) { } func (l *logger) Warn(tag, msg string, args ...interface{}) { - if l.level > LevelWarn && !l.forcedDebug { + if l.getLogLevel(tag) > LevelWarn && !l.forcedDebug { return } @@ -138,7 +149,7 @@ func (l *logger) Warn(tag, msg string, args ...interface{}) { } func (l *logger) Error(tag, msg string, args ...interface{}) { - if l.level > LevelError && !l.forcedDebug { + if l.getLogLevel(tag) > LevelError && !l.forcedDebug { return } @@ -190,3 +201,12 @@ func (l *logger) printf(tag, msg string, args ...interface{}) { l.logger.Output(2, s) l.loggerMu.Unlock() } + +func (l *logger) getLogLevel(tag string) LogLevel { + for _, logTag := range l.tags { + if logTag.Name == tag { + return logTag.LogLevel + } + } + return l.level +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b5a0953a..689abafd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -23,7 +23,7 @@ github.com/charlievieth/fs ## explicit; go 1.21 github.com/cloudfoundry/bosh-cpi-go/apiv1 github.com/cloudfoundry/bosh-cpi-go/rpc -# github.com/cloudfoundry/bosh-utils v0.0.424 +# github.com/cloudfoundry/bosh-utils v0.0.425 ## explicit; go 1.21 github.com/cloudfoundry/bosh-utils/errors github.com/cloudfoundry/bosh-utils/logger