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

68 lines
1.2 KiB
Go

package logger
import (
"mygo/conf"
"github.com/zxysilent/logs"
)
var mylog *logs.Logger
//logger.Debug("你好啊")
//logger.Info("你好啊")
//logger.Warn("你好啊")
//loggerError("你好啊")
func init() {
mylog = logs.NewLogger("./logs/debug.log")
if conf.ISTEST {
mylog.SetLevel(logs.LDEBUG)
mylog.SetCaller(true)
// 设置同时显示到控制台
// 默认只输出到文件
mylog.SetConsole(true)
} else {
mylog = logs.NewLogger("./logs/info.log")
mylog.SetLevel(logs.LINFO)
}
}
func Debug(args ...interface{}) {
defer mylog.Flush()
mylog.Debug(args...)
}
func Debugf(format string, args ...interface{}) {
defer mylog.Flush()
mylog.Debug(args...)
}
func Info(args ...interface{}) {
defer mylog.Flush()
mylog.Info(args...)
}
func Infof(format string, args ...interface{}) {
defer mylog.Flush()
mylog.Infof(format, args...)
}
func Warn(args ...interface{}) {
defer mylog.Flush()
mylog.Warn(args...)
}
func Warnf(format string, args ...interface{}) {
defer mylog.Flush()
mylog.Warnf(format, args...)
}
func Error(args ...interface{}) {
defer mylog.Flush()
mylog.Error(args...)
}
func Errorf(format string, args ...interface{}) {
defer mylog.Flush()
mylog.Errorf(format, args...)
}