mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 17:51:39 +00:00
replace logger with go-logging
This commit is contained in:
44
common/logging.go
Normal file
44
common/logging.go
Normal file
@ -0,0 +1,44 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
stdlog "log"
|
||||
"os"
|
||||
|
||||
"github.com/op/go-logging"
|
||||
)
|
||||
|
||||
var Log = logging.MustGetLogger("main")
|
||||
|
||||
func init() {
|
||||
// Customize the output format
|
||||
logging.SetFormatter(logging.MustStringFormatter("▶ %{level:.1s} 0x%{id:x} %{message}"))
|
||||
|
||||
// Setup one stdout and one syslog backend.
|
||||
logBackend := logging.NewLogBackend(os.Stderr, "", stdlog.LstdFlags|stdlog.Lshortfile)
|
||||
logBackend.Color = true
|
||||
|
||||
syslogBackend, err := logging.NewSyslogBackend("")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Combine them both into one logging backend.
|
||||
logging.SetBackend(logBackend, syslogBackend)
|
||||
|
||||
// Test
|
||||
/*
|
||||
Log.Debug("debug")
|
||||
Log.Info("info")
|
||||
Log.Notice("notice")
|
||||
Log.Warning("warning")
|
||||
Log.Error("error")
|
||||
*/
|
||||
}
|
||||
|
||||
var Debug = Log.Debug
|
||||
var Info = Log.Info
|
||||
var Notice = Log.Notice
|
||||
var Warning = Log.Warning
|
||||
var Warn = Log.Warning
|
||||
var Error = Log.Error
|
||||
var Critical = Log.Critical
|
Reference in New Issue
Block a user