-
Notifications
You must be signed in to change notification settings - Fork 12
/
default.go
79 lines (69 loc) · 1.45 KB
/
default.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
package conf
import (
"fmt"
"strings"
)
//日志级别
type Level int8
const (
DebugLevel Level = iota
InfoLevel
WarnLevel
ErrorLevel
PanicLevel
FatalLevel
)
func (level Level) String() string {
switch level {
case DebugLevel:
return "debug"
case InfoLevel:
return "info"
case WarnLevel:
return "warning"
case ErrorLevel:
return "error"
case FatalLevel:
return "fatal"
case PanicLevel:
return "panic"
}
return "unknown"
}
func ParseLevel(lvl string) (Level, error) {
switch strings.ToLower(lvl) {
case "panic", "dpanic":
return PanicLevel, nil
case "fatal":
return FatalLevel, nil
case "error":
return ErrorLevel, nil
case "warn", "warning":
return WarnLevel, nil
case "info":
return InfoLevel, nil
case "debug":
return DebugLevel, nil
}
var l Level
return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
}
var AllLevels = []Level{
PanicLevel,
FatalLevel,
ErrorLevel,
WarnLevel,
InfoLevel,
DebugLevel,
}
//默认参数
const (
LogPath string = "/var/log" //日志保存路径
LogName string = "output" //日志保存的名称,不些随机生成
LogLevel string = "debug" //日志记录级别
MaxSize int = 100 //日志分割的尺寸 MB
MaxAge int = 7 //分割日志保存的时间 day
Stacktrace string = "error" //记录堆栈的级别
IsStdOut string = "yes" //是否标准输出console输出
ProjectName string = "test" //项目名称
)