-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.go
73 lines (62 loc) · 1.71 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
// Copyright (C) 2019-2020, Xiongfa Li.
// @author xiongfa.li
// @version V1.0
// Description:
package xlog
type LogDebug interface {
DebugEnabled() bool
Debug(args ...interface{})
Debugln(args ...interface{})
Debugf(fmt string, args ...interface{})
}
type LogInfo interface {
InfoEnabled() bool
Info(args ...interface{})
Infoln(args ...interface{})
Infof(fmt string, args ...interface{})
}
type LogWarn interface {
WarnEnabled() bool
Warn(args ...interface{})
Warnln(args ...interface{})
Warnf(fmt string, args ...interface{})
}
type LogError interface {
ErrorEnabled() bool
Error(args ...interface{})
Errorln(args ...interface{})
Errorf(fmt string, args ...interface{})
}
type LogPanic interface {
PanicEnabled() bool
Panic(args ...interface{})
Panicln(args ...interface{})
Panicf(fmt string, args ...interface{})
}
type LogFatal interface {
FatalEnabled() bool
Fatal(args ...interface{})
Fatalln(args ...interface{})
Fatalf(fmt string, args ...interface{})
}
// Logger是xlog的日志封装工具,实现了常用的日志方法
type Logger interface {
// Debug级别日志接口
LogDebug
// Info级别日志接口
LogInfo
// Warn级别日志接口
LogWarn
// Error级别日志接口
LogError
// Panic级别日志接口,注意会触发Panic
LogPanic
// Fatal级别日志接口,注意会触发程序退出
LogFatal
// 附加日志名称,注意会附加父Logger的名称,格式为:父Logger名称 + '.' + name
WithName(name string) Logger
// 附加日志信息,注意会附加父Logger的附加信息,如果相同则会覆盖
WithFields(keyAndValues ...interface{}) Logger
// 配置日志的调用深度,注意会在父Logger的基础上调整深度
WithDepth(depth int) Logger
}