-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogging_wrapper.go
More file actions
65 lines (50 loc) · 1.62 KB
/
logging_wrapper.go
File metadata and controls
65 lines (50 loc) · 1.62 KB
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
// Copyright (C) 2019-2020, Xiongfa Li.
// @author xiongfa.li
// @version V1.0
// Description:
package xlog
import "io"
type LevelHook func(Level) Level
type hookLevelLogging struct {
logging Logging
hook LevelHook
}
func NewHookLevelLogging(logging Logging, hook LevelHook) *hookLevelLogging {
return &hookLevelLogging{
logging: logging,
hook: hook,
}
}
func (l *hookLevelLogging) Logf(level Level, depth int, keyValues KeyValues, format string, args ...interface{}) {
l.logging.Logf(l.hook(level), depth+1, keyValues, format, args...)
}
func (l *hookLevelLogging) Log(level Level, depth int, keyValues KeyValues, args ...interface{}) {
l.logging.Log(l.hook(level), depth+1, keyValues, args...)
}
func (l *hookLevelLogging) Logln(level Level, depth int, keyValues KeyValues, args ...interface{}) {
l.logging.Logln(l.hook(level), depth+1, keyValues, args...)
}
func (l *hookLevelLogging) SetFormatter(f Formatter) {
l.logging.SetFormatter(f)
}
func (l *hookLevelLogging) SetSeverityLevel(severityLevel Level) {
l.logging.SetSeverityLevel(severityLevel)
}
func (l *hookLevelLogging) IsEnabled(severityLevel Level) bool {
return l.logging.IsEnabled(severityLevel)
}
func (l *hookLevelLogging) SetOutput(w io.Writer) {
l.logging.SetOutput(w)
}
func (l *hookLevelLogging) SetOutputBySeverity(severityLevel Level, w io.Writer) {
l.logging.SetOutputBySeverity(severityLevel, w)
}
func (l *hookLevelLogging) GetOutputBySeverity(severity Level) io.Writer {
return l.logging.GetOutputBySeverity(severity)
}
func (l *hookLevelLogging) Clone() Logging {
return &hookLevelLogging{
logging: l.logging.Clone(),
hook: l.hook,
}
}