-
Notifications
You must be signed in to change notification settings - Fork 3
/
noop.go
46 lines (34 loc) · 911 Bytes
/
noop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2017. Oleg Sklyar & teris.io. All rights reserved.
// See the LICENSE file in the project root for licensing information.
package log
import "time"
// implements a no-operation logger so that the logger interface can be used
// out of the box without providing an actual implementation
type noop struct{}
var (
_ Factory = (*noop)(nil)
_ Logger = (*noop)(nil)
)
func (n *noop) New() Logger {
return &noop{}
}
func (n *noop) Threshold(lvl LoggerLevel) {
}
func (n *noop) Level(lvl LoggerLevel) Logger {
return n
}
func (n *noop) Field(k string, v interface{}) Logger {
return n
}
func (n *noop) Fields(data map[string]interface{}) Logger {
return n
}
func (n *noop) Error(err error) Logger {
return n
}
func (n *noop) Log(msg string) Tracer {
return NewTracer(n, time.Now())
}
func (n *noop) Logf(format string, v ...interface{}) Tracer {
return NewTracer(n, time.Now())
}