2014-04-14 02:17:20 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-12-02 02:53:16 +03:00
|
|
|
"github.com/Sirupsen/logrus"
|
2017-02-06 03:10:19 +03:00
|
|
|
"os"
|
2014-04-14 02:17:20 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
var log = logrus.New()
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
log.Formatter = new(logrus.JSONFormatter)
|
|
|
|
log.Formatter = new(logrus.TextFormatter) // default
|
2015-03-09 18:40:44 +03:00
|
|
|
log.Level = logrus.DebugLevel
|
2014-04-14 02:17:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2014-11-05 21:49:58 +03:00
|
|
|
defer func() {
|
|
|
|
err := recover()
|
|
|
|
if err != nil {
|
|
|
|
log.WithFields(logrus.Fields{
|
|
|
|
"omg": true,
|
|
|
|
"err": err,
|
|
|
|
"number": 100,
|
|
|
|
}).Fatal("The ice breaks!")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2015-03-09 18:40:44 +03:00
|
|
|
log.WithFields(logrus.Fields{
|
|
|
|
"animal": "walrus",
|
|
|
|
"number": 8,
|
|
|
|
}).Debug("Started observing beach")
|
|
|
|
|
2014-04-14 02:17:20 +04:00
|
|
|
log.WithFields(logrus.Fields{
|
|
|
|
"animal": "walrus",
|
|
|
|
"size": 10,
|
|
|
|
}).Info("A group of walrus emerges from the ocean")
|
|
|
|
|
|
|
|
log.WithFields(logrus.Fields{
|
|
|
|
"omg": true,
|
|
|
|
"number": 122,
|
|
|
|
}).Warn("The group's number increased tremendously!")
|
|
|
|
|
2015-03-09 18:40:44 +03:00
|
|
|
log.WithFields(logrus.Fields{
|
|
|
|
"temperature": -4,
|
|
|
|
}).Debug("Temperature changes")
|
|
|
|
|
2014-04-14 02:17:20 +04:00
|
|
|
log.WithFields(logrus.Fields{
|
2014-11-05 21:49:58 +03:00
|
|
|
"animal": "orca",
|
|
|
|
"size": 9009,
|
|
|
|
}).Panic("It's over 9000!")
|
2014-04-14 02:17:20 +04:00
|
|
|
}
|