You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
890 B

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:.4s}] %{shortfile:-20s} %{message}"))
// Setup one stdout and one syslog backend.
logBackend := logging.NewLogBackend(os.Stderr, "", stdlog.LstdFlags)
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