logrus/examples/text.go

38 lines
738 B
Go
Raw Normal View History

2014-03-11 03:22:08 +04:00
package main
import (
"github.com/Sirupsen/logrus"
)
func main() {
log := logrus.New()
2014-03-11 03:59:18 +04:00
log.Formatter = new(logrus.JSONFormatter)
2014-03-11 03:22:08 +04:00
for {
log.WithFields(logrus.Fields{
"animal": "walrus",
2014-03-15 00:17:18 +04:00
"size": 10,
2014-03-11 03:59:18 +04:00
}).Print("A group of walrus emerges from the ocean")
2014-03-11 03:22:08 +04:00
log.WithFields(logrus.Fields{
"omg": true,
"number": 122,
2014-03-11 03:59:18 +04:00
}).Warn("The group's number increased tremendously!")
2014-03-11 03:22:08 +04:00
log.WithFields(logrus.Fields{
"animal": "walrus",
2014-03-15 00:17:18 +04:00
"size": 10,
2014-03-11 03:59:18 +04:00
}).Print("A giant walrus appears!")
2014-03-11 03:22:08 +04:00
log.WithFields(logrus.Fields{
"animal": "walrus",
2014-03-15 00:17:18 +04:00
"size": 9,
2014-03-11 03:59:18 +04:00
}).Print("Tremendously sized cow enters the ocean.")
2014-03-11 03:22:08 +04:00
log.WithFields(logrus.Fields{
"omg": true,
2014-03-11 03:59:18 +04:00
"number": 100,
}).Fatal("The ice breaks!")
2014-03-11 03:22:08 +04:00
}
}