/
logger.go
76 lines (63 loc) · 2.5 KB
/
logger.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package logger
/*
Logger defines a common logger interface for packages that accept an
injected logger. It fully implements the standard 'pkg/log' log package
logging methods as well Info, Warn, Error, and Debug level equivalents.
The Info* methods are expected to mirror the Print* methods.
Packages that implement this interface should support level codes and
expect usage as follows:
- Panic, highest level of severity. Log and then call panic.
- Fatal, log and then call `os.Exit(<code>)` with a non-zero value.
- Error, used for errors that should definitely be noted and addressed.
- Warn, non-critical information about undesirable behavior that needs
to be addressed in some way.
- Info, general operational information about what's happening inside an
application. 'Print' methods should output Info-level information.
- Debug, usually only enabled when debugging. Add anything useful, but
still exclude PII or sensitive data...
Each level should include all the log levels above it. To manage the output,
this interface also implements a SetLevel(level uint) method that defines
the log level of this logger.
Compatible logger packages include:
- "github.com/bdlm/log"
- "github.com/sirupsen/logrus"
*/
type Logger interface {
// WithFields adds a map of key/value data to the log entry.
WithFields(Fields)
// SetLevel sets the log level of this logger. Accepts any unsigned
// integer.
SetLevel(level Level)
// Fatal methods should call os.Exit() with a non-zero exit status.
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Fatalln(args ...interface{})
// Level 1
// Panic methods should end with a call to the panic() builtin to
// allow recovery, regardless of log level, but should not attempt to
// write to any logs independent of that if the log level is below
// PanicLevel.
Panic(args ...interface{})
Panicf(format string, args ...interface{})
Panicln(args ...interface{})
// Level 2
Error(args ...interface{})
Errorf(format string, args ...interface{})
Errorln(args ...interface{})
// Level 3
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Warnln(args ...interface{})
// Level 4
Info(args ...interface{})
Infof(format string, args ...interface{})
Infoln(args ...interface{})
// pkg/log compatiblity, alias to Info* methods.
Print(args ...interface{})
Printf(format string, args ...interface{})
Println(args ...interface{})
// Level 5
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Debugln(args ...interface{})
}