-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
logger.go
36 lines (32 loc) · 801 Bytes
/
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
package main
import (
"github.com/Sirupsen/logrus"
)
func setLogger(level, format string) {
switch level {
case "debug", "d":
Logger.Level = logrus.DebugLevel
case "info", "i":
Logger.Level = logrus.InfoLevel
case "warn", "w":
Logger.Level = logrus.WarnLevel
case "error", "e":
Logger.Level = logrus.ErrorLevel
case "fatal", "f":
Logger.Level = logrus.FatalLevel
case "panic", "p":
Logger.Level = logrus.PanicLevel
default:
Logger.Level = logrus.InfoLevel
}
switch format {
case "text", "t":
Logger.Formatter = new(logrus.TextFormatter)
case "json", "j":
Logger.Formatter = new(logrus.JSONFormatter)
case "force-color", "fc":
Logger.Formatter = &logrus.TextFormatter{ForceColors: true}
default:
Logger.Formatter = &logrus.TextFormatter{ForceColors: true}
}
}