Files
grafana/pkg/util/errutil/log.go
Dimitris Sotirakis a807c04177 [v9.3.x] Chore: Upgrade Go to 1.20.1 and Alpine to 3.17 (#63891) (#66455)
* CI: Split  subcommand (#66005)

* Update e2e package

- Ensure health request is monitored for addDatasource flow
- Add custom timeout to configurePanel flow

(cherry picked from commit 155fcae4aa)

* Make health check optional

(cherry picked from commit 91f66d61e1)

---------

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
2023-04-13 16:57:19 +03:00

38 lines
967 B
Go

package errutil
type LogLevel string
const (
LevelUnknown LogLevel = ""
LevelNever LogLevel = "never"
LevelDebug LogLevel = "debug"
LevelInfo LogLevel = "info"
LevelWarn LogLevel = "warn"
LevelError LogLevel = "error"
)
// LogInterface is a subset of github.com/grafana/grafana/pkg/infra/log.Logger
// to avoid having to depend on other packages in the module so that
// there's no risk of circular dependencies.
type LogInterface interface {
Debug(msg string, ctx ...interface{})
Info(msg string, ctx ...interface{})
Warn(msg string, ctx ...interface{})
Error(msg string, ctx ...interface{})
}
func (l LogLevel) LogFunc(logger LogInterface) func(msg string, ctx ...interface{}) {
switch l {
case LevelNever:
return func(_ string, _ ...interface{}) {}
case LevelDebug:
return logger.Debug
case LevelInfo:
return logger.Info
case LevelWarn:
return logger.Warn
default: // LevelUnknown and LevelError.
return logger.Error
}
}