grafana/pkg/plugins/log/fake.go
Will Browne ec82719372
Plugins: Introduce plugin package specific logger (#62204)
* refactor

* implement with infra log for now

* undo moving

* update package name

* update name

* fix tests

* update pretty signature

* update naming

* simplify

* fix typo

* delete comment

* fix import

* retrigger
2023-02-28 16:10:27 +01:00

49 lines
884 B
Go

package log
var _ Logger = (*TestLogger)(nil)
type TestLogger struct {
DebugLogs Logs
InfoLogs Logs
WarnLogs Logs
ErrorLogs Logs
}
func NewTestLogger() *TestLogger {
return &TestLogger{}
}
func (f *TestLogger) New(_ ...interface{}) Logger {
return NewTestLogger()
}
func (f *TestLogger) Info(msg string, ctx ...interface{}) {
f.InfoLogs.Calls++
f.InfoLogs.Message = msg
f.InfoLogs.Ctx = ctx
}
func (f *TestLogger) Warn(msg string, ctx ...interface{}) {
f.WarnLogs.Calls++
f.WarnLogs.Message = msg
f.WarnLogs.Ctx = ctx
}
func (f *TestLogger) Debug(msg string, ctx ...interface{}) {
f.DebugLogs.Calls++
f.DebugLogs.Message = msg
f.DebugLogs.Ctx = ctx
}
func (f *TestLogger) Error(msg string, ctx ...interface{}) {
f.ErrorLogs.Calls++
f.ErrorLogs.Message = msg
f.ErrorLogs.Ctx = ctx
}
type Logs struct {
Calls int
Message string
Ctx []interface{}
}