package log /* override the log */ import "fmt" import "strings" import origlog "log" import "github.com/sirupsen/logrus" var newlog = logrus.New() var systemdlog *logrus.Logger var debug bool = false var warn bool = false var err bool = false type Log struct { Debug bool Warn bool Err bool } func New() *Log { var tmp Log return &tmp } func SetDebug(a bool) { debug = a } func SetWarn(a bool) { warn = a } func SetError(a bool) { err = a } func (a *Log) Printer(b string) { origlog.Println(b) } func Print(a ...interface{}) { origlog.Println(a) } func Println(format string, a ...interface{}) { // if (debug) { // newlog.Println(a) // } var tmp string if (a == nil) { tmp = fmt.Sprintf(format) } else { tmp = fmt.Sprintf(format, a) } // log each line lines := strings.Split(Chomp(tmp), "\n") for _, line := range lines { origlog.Println(line) } } func Debug(format string, a ...interface{}) { if (debug) { newlog.Debug(format, a) systemdlog.Println("SYSTEMLOG:", format, a) } } func Debugln(a ...interface{}) { if (debug) { newlog.Debug(a) systemdlog.Println("SYSTEMLOG:", a) } } func Warn(a ...interface{}) { origlog.Println(a) } func Error(a ...interface{}) { origlog.Println(a) }