-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.go
30 lines (26 loc) · 796 Bytes
/
basic.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
package main
import "github.com/sirupsen/logrus"
func main() {
logrus.Info("log without option")
logrus.Debug("this log will not be printed case default level is INFO")
logrus.SetLevel(logrus.DebugLevel)
logrus.Debug("this debug log will be printed")
logrus.SetLevel(logrus.ErrorLevel)
logrus.Info("this info log will not be printed")
logrus.SetLevel(logrus.InfoLevel)
logrus.Info("this info log will be printed")
logrus.WithFields(
logrus.Fields{
"foo": "bar",
},
).Info("print log with some external fields")
contextLog := logrus.WithField("ctx1", "value1")
contextLog.Info("will print log with ctx1")
contextLog2 := logrus.WithFields(
logrus.Fields{
"ctx2": "value2",
"ctx3": "value3",
},
)
contextLog2.Info("will print log with multiple context fields")
}