日志屏幕输出

This commit is contained in:
boyce
2019-03-19 17:23:50 +08:00
parent 2c23d7fbd9
commit 7a215e6a83
5 changed files with 30 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ var LogPrefix = [LEVEL_MAX]string{"[UNKNOW]", "[DEBUG]", "[INFO ]", "[WARN ]", "
type ILogger interface {
Printf(level uint, format string, v ...interface{})
Print(level uint, v ...interface{})
SetLogLevel(level uint)
}
type LogModule struct {
@@ -93,6 +94,10 @@ func (slf *LogModule) Printf(level uint, format string, v ...interface{}) {
return
}
if slf.openLevel == LEVER_DEBUG {
fmt.Println(LogPrefix[level], fmt.Sprintf(format, v...))
}
slf.CheckAndGenFile()
slf.GetLoggerByLevel(level).Output(slf.calldepth, fmt.Sprintf(format, v...))
}
@@ -102,6 +107,10 @@ func (slf *LogModule) Print(level uint, v ...interface{}) {
return
}
if slf.openLevel == LEVER_DEBUG {
fmt.Println(LogPrefix[level], fmt.Sprint(v...))
}
slf.CheckAndGenFile()
slf.GetLoggerByLevel(level).Output(slf.calldepth, fmt.Sprint(v...))
}
@@ -109,3 +118,7 @@ func (slf *LogModule) Print(level uint, v ...interface{}) {
func (slf *LogModule) AppendCallDepth(calldepth int) {
slf.calldepth += calldepth
}
func (slf *LogModule) SetLogLevel(level uint) {
slf.openLevel = level
}