100 lines
1.9 KiB
Go
100 lines
1.9 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 SetLogLevelByName(newlv string) (oldlv string) {
|
|
return mylog.SetLogLevelByName(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.Errorf(format, v...)
|
|
}
|
|
|
|
func Panicf(format string, v ...interface{}) {
|
|
mylog.Panicf(format, v...)
|
|
}
|
|
|
|
func Fatalf(format string, v ...interface{}) {
|
|
mylog.Fatalf(format, v...)
|
|
}
|
|
|
|
func Fatal(v ...interface{}){
|
|
mylog.Fatal(v...)
|
|
}
|
|
|
|
func Println(v ...interface{}){
|
|
mylog.Println(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()))
|
|
}
|