|
|
|
@ -35,7 +35,7 @@ func generateCoreLogStr(skip int, logstr string) string {
|
|
|
|
|
return logStr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) build(thread string, isStd bool, isShow bool, handler func([]Attr, string), level int, logDetail string) {
|
|
|
|
|
func (logger *starlog) build(thread string, isStd bool, isShow bool, handler func(data LogData), level int, logDetail string) {
|
|
|
|
|
logger.mu.Lock()
|
|
|
|
|
defer logger.mu.Unlock()
|
|
|
|
|
var skip, line int = 3, 0
|
|
|
|
@ -80,19 +80,33 @@ func (logger *starlog) build(thread string, isStd bool, isShow bool, handler fun
|
|
|
|
|
}
|
|
|
|
|
if isShow {
|
|
|
|
|
if !logger.showColor {
|
|
|
|
|
fmt.Print(logStr)
|
|
|
|
|
if level >= logger.errOutputLevel {
|
|
|
|
|
fmt.Fprint(os.Stderr, logStr)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Print(logStr)
|
|
|
|
|
}
|
|
|
|
|
} else if !logger.onlyColorLevel {
|
|
|
|
|
//logcolor := NewColor(logger.colorList[level]...)
|
|
|
|
|
logger.colorMe[level].Fprint(stdScreen, logStr)
|
|
|
|
|
if level < logger.errOutputLevel {
|
|
|
|
|
logger.colorMe[level].Fprint(stdScreen, logStr)
|
|
|
|
|
} else {
|
|
|
|
|
logger.colorMe[level].Fprint(errScreen, logStr)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Fprint(stdScreen, logStr)
|
|
|
|
|
if level < logger.errOutputLevel {
|
|
|
|
|
fmt.Fprint(stdScreen, logStr)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Fprint(errScreen, logStr)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if handler != nil {
|
|
|
|
|
stacks.Push(logTransfer{
|
|
|
|
|
handlerFunc: handler,
|
|
|
|
|
colors: logger.colorList[level],
|
|
|
|
|
logStr: logStr,
|
|
|
|
|
LogData: LogData{
|
|
|
|
|
Log: logStr,
|
|
|
|
|
Colors: logger.colorList[level],
|
|
|
|
|
Name: logger.name,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if !logger.stopWriter {
|
|
|
|
@ -130,133 +144,133 @@ func (logger *starlog) println(str ...interface{}) string {
|
|
|
|
|
return fmt.Sprintln(str...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Debug(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Debug(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvDebug, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Debugf(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Debugf(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvDebug, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Debugln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Debugln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvDebug, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Info(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Info(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvInfo, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Infof(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Infof(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvInfo, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Infoln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Infoln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvInfo, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Notice(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Notice(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvNotice, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Noticef(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Noticef(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvNotice, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Noticeln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Noticeln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvNotice, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Warning(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Warning(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvWarning, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Warningf(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Warningf(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvWarning, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Warningln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Warningln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvWarning, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Error(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Error(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvError, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Errorf(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Errorf(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvError, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Errorln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Errorln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvError, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Critical(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Critical(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvCritical, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Criticalf(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Criticalf(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvCritical, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Criticalln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Criticalln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvCritical, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Fatal(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Fatal(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvFatal, strs)
|
|
|
|
|
os.Exit(9)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Fatalf(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Fatalf(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvFatal, strs)
|
|
|
|
|
os.Exit(9)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Fatalln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Fatalln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvFatal, strs)
|
|
|
|
|
os.Exit(9)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Panic(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Panic(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvPanic, strs)
|
|
|
|
|
panic(str)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Panicf(thread string, isStd bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Panicf(thread string, isStd bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvPanic, strs)
|
|
|
|
|
panic(fmt.Sprintf(format, str...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Panicln(thread string, isStd bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Panicln(thread string, isStd bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, logger.showStd, handler, LvPanic, strs)
|
|
|
|
|
panic(fmt.Sprintln(str...))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Print(thread string, isStd bool, isShow bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Print(thread string, isStd bool, isShow bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
if isShow {
|
|
|
|
|
fmt.Print(strs)
|
|
|
|
@ -264,7 +278,7 @@ func (logger *starlog) Print(thread string, isStd bool, isShow bool, handler fun
|
|
|
|
|
logger.write(strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Printf(thread string, isStd bool, isShow bool, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Printf(thread string, isStd bool, isShow bool, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
if isShow {
|
|
|
|
|
fmt.Print(strs)
|
|
|
|
@ -272,7 +286,7 @@ func (logger *starlog) Printf(thread string, isStd bool, isShow bool, handler fu
|
|
|
|
|
logger.write(strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Println(thread string, isStd bool, isShow bool, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Println(thread string, isStd bool, isShow bool, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
if isShow {
|
|
|
|
|
fmt.Print(strs)
|
|
|
|
@ -280,17 +294,32 @@ func (logger *starlog) Println(thread string, isStd bool, isShow bool, handler f
|
|
|
|
|
logger.write(strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Log(thread string, isStd bool, isShow bool, level int, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Log(thread string, isStd bool, isShow bool, level int, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.build(thread, isStd, isShow, handler, level, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Logf(thread string, isStd bool, isShow bool, level int, handler func([]Attr, string), format string, str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Logf(thread string, isStd bool, isShow bool, level int, handler func(LogData), format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.build(thread, isStd, isShow, handler, level, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Logln(thread string, isStd bool, isShow bool, level int, handler func([]Attr, string), str ...interface{}) {
|
|
|
|
|
func (logger *starlog) Logln(thread string, isStd bool, isShow bool, level int, handler func(LogData), str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.build(thread, isStd, isShow, handler, level, strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Write(str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprint(str...)
|
|
|
|
|
logger.Write(strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Writef(format string, str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintf(format, str...)
|
|
|
|
|
logger.Write(strs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (logger *starlog) Writeln(str ...interface{}) {
|
|
|
|
|
strs := fmt.Sprintln(str...)
|
|
|
|
|
logger.Write(strs)
|
|
|
|
|
}
|
|
|
|
|