88 lines
1.7 KiB
Go
88 lines
1.7 KiB
Go
package log
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"runtime"
|
|
)
|
|
|
|
func GetLogid() string {
|
|
if logidCreator != nil {
|
|
return logidCreator.GetLogid()
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func SetLogid(logid string) {
|
|
if logidCreator != nil {
|
|
logidCreator.SetLogid(logid)
|
|
}
|
|
}
|
|
|
|
func Cleanup() {
|
|
if logidCreator != nil {
|
|
logidCreator.Cleanup()
|
|
}
|
|
}
|
|
|
|
func SetLogLevel(newlv logLevel) (oldlv logLevel) {
|
|
return mylog.SetLogLevel(newlv)
|
|
}
|
|
|
|
func PrintPretty(prefix string, v interface{}) {
|
|
mylog.PrintPretty(prefix, v)
|
|
}
|
|
|
|
func DebugfWithDepth(calldepth int, format string, v ...interface{}) {
|
|
mylog.DebugfWithDepth(calldepth, format, v...)
|
|
}
|
|
|
|
func Debugf(format string, v ...interface{}) {
|
|
mylog.Debugf(format, v...)
|
|
}
|
|
|
|
func Noticef(format string, v ...interface{}) {
|
|
mylog.Noticef(format, v...)
|
|
}
|
|
|
|
func NoticefWithDepth(calldepth int, format string, v ...interface{}) {
|
|
mylog.NoticefWithDepth(calldepth, format, v...)
|
|
}
|
|
|
|
func Infof(format string, v ...interface{}) {
|
|
mylog.Infof(format, v...)
|
|
}
|
|
|
|
func Warningf(format string, v ...interface{}) {
|
|
mylog.Warningf(format, v...)
|
|
}
|
|
|
|
func Errorf(format string, v ...interface{}) {
|
|
mylog.Warningf(format, v...)
|
|
}
|
|
|
|
func Panicf(format string, v ...interface{}) {
|
|
mylog.Panicf(format, v...)
|
|
}
|
|
|
|
func Fatalf(format string, v ...interface{}) {
|
|
mylog.Fatalf(format, v...)
|
|
}
|
|
|
|
func TraceInto(format string, v ...interface{}) string {
|
|
_, fn, line, _ := runtime.Caller(1)
|
|
strfn := fmt.Sprintf("%s:%d", fn, line)
|
|
Debugf("TRACE into ["+strfn+"]"+format+"...\r\n", v...)
|
|
|
|
return strfn
|
|
}
|
|
|
|
func TraceExit(strfn string, format string, v ...interface{}) {
|
|
Debugf("TRACE exit ["+strfn+"]"+format+"...\r\n", v...)
|
|
}
|
|
|
|
func RegisterLogidCreator(idc LogidCreator) {
|
|
logidCreator = idc
|
|
SetLogid(fmt.Sprintf("sysinit(%d)", os.Getpid()))
|
|
}
|