BlackForest/Log.go

79 lines
2.0 KiB
Go
Raw Permalink Normal View History

package main
import "blacktea.vip.cpolar.top/OrgGo/simplelog"
type Loger struct {
*simplelog.SimpleLog
}
type EULogType int
const (
LevelTrace EULogLevel = simplelog.LevelTrace
LevelDebug EULogLevel = simplelog.LevelDebug
LevelInfo EULogLevel = simplelog.LevelInfo
LevelWarn EULogLevel = simplelog.LevelWarn
LevelError EULogLevel = simplelog.LevelError
LevelFatal EULogLevel = simplelog.LevelFatal
)
type EULogLevel int
func (my *Loger) Init(file string, LogLevel EULogLevel) *Loger {
switch file {
case "":
my.SimpleLog = new(simplelog.SimpleLog).InitStd(int(LogLevel), simplelog.Ltime|simplelog.Lfile|simplelog.Llevel)
default:
my.SimpleLog = new(simplelog.SimpleLog).InitRotating(file, 1024*1000, 10, int(LogLevel))
}
return my
}
func (my *Loger) Trace(v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelTrace, "", v...)
}
func (my *Loger) Debug(v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelDebug, "", v...)
}
func (my *Loger) Info(v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelInfo, "", v...)
}
func (my *Loger) Warn(v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelWarn, "", v...)
}
func (my *Loger) Error(v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelError, "", v...)
}
func (my *Loger) Fatal(v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelFatal, "", v...)
}
func (my *Loger) Tracef(format string, v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelTrace, format, v...)
}
func (my *Loger) Debugf(format string, v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelDebug, format, v...)
}
func (my *Loger) Infof(format string, v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelInfo, format, v...)
}
func (my *Loger) Warnf(format string, v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelWarn, format, v...)
}
func (my *Loger) Errorf(format string, v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelError, format, v...)
}
func (my *Loger) Fatalf(format string, v ...interface{}) {
my.SimpleLog.Output(2, simplelog.LevelFatal, format, v...)
}