-
Notifications
You must be signed in to change notification settings - Fork 4
/
iface.go
91 lines (77 loc) · 2.42 KB
/
iface.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package suplog
import (
"context"
"io"
"time"
)
// Logger represents a full suplogger interface.
// It was inspired by previous ClassicLogger interface that we have to support,
// also logrus capabilities that are added here just recently.
type Logger interface {
// Core logging methods
Success(format string, args ...interface{})
Warning(format string, args ...interface{})
Error(format string, args ...interface{})
Debug(format string, args ...interface{})
// Logrus context providers
WithField(key string, value interface{}) Logger
WithFields(fields Fields) Logger
WithError(err error) Logger
WithContext(ctx context.Context) Logger
WithTime(t time.Time) Logger
// Logrus formatted logging methods
Logf(level Level, format string, args ...interface{})
Tracef(format string, args ...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Printf(format string, args ...interface{})
Warningf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Panicf(format string, args ...interface{})
// Logrus shortcut logging methods
Log(level Level, args ...interface{})
Trace(args ...interface{})
Info(args ...interface{})
Print(args ...interface{})
Fatal(args ...interface{})
Panic(args ...interface{})
Logln(level Level, args ...interface{})
Traceln(args ...interface{})
Debugln(args ...interface{})
Infoln(args ...interface{})
Println(args ...interface{})
Warningln(args ...interface{})
Errorln(args ...interface{})
Fatalln(args ...interface{})
Panicln(args ...interface{})
}
type LoggerConfigurator interface {
SetFormatter(formatter Formatter)
SetOutput(suplog io.Writer)
SetLevel(level Level)
GetLevel() Level
IsLevelEnabled(level Level) bool
AddHook(hook Hook)
ReplaceHooks(hooks LevelHooks) LevelHooks
SetStackTraceOffset(offset int)
CallerName() string
}
var (
_ StdLogger = &suplogger{}
_ StdLogger = &Entry{}
)
// StdLogger is what your suplog-enabled library should take, that way
// it'll accept a stdlib logger (*log.Logger) and an suplog.Logger. There's no standard
// interface, this is the closest we get, unfortunately.
type StdLogger interface {
Print(...interface{})
Printf(string, ...interface{})
Println(...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Fatalln(...interface{})
Panic(...interface{})
Panicf(string, ...interface{})
Panicln(...interface{})
}