````golang
package main
import (
"fmt"
"github.com/sirupsen/logrus"
"os"
)
var log = logrus.New()
func main() {
log.Out = os.Stdout
registerLogger := log.WithFields(logrus.Fields{
"animal": "walrus",
"size": 10,
})
registerLogger.Info("a info")
fmt.Println("--------------------------------------------------")
registerLogger.Warn("a warn")
fmt.Println("--------------------------------------------------")
log.WithFields(logrus.Fields{
"animal": "walrus",
"size": 10,
}).Info("A group of walrus emerges from the ocean")
fmt.Println("--------------------------------------------------")
log.WithFields(logrus.Fields{
"animal": "walrus",
"size": 10,
}).Fatal("A group of walrus emerges from the ocean") //usage:fatal error
fmt.Println("--------------------------------------------------")
}
````
有疑问加站长微信联系(非本文作者))