qoobing.com/gomod/log@v1.2.8/global.go (about) 1 package log 2 3 import ( 4 "fmt" 5 "os" 6 "runtime" 7 ) 8 9 func GetLogid() string { 10 if logidCreator != nil { 11 return logidCreator.GetLogid() 12 } 13 return "" 14 } 15 16 func SetLogid(logid string) { 17 if logidCreator != nil { 18 logidCreator.SetLogid(logid) 19 } 20 } 21 22 func Cleanup() { 23 if logidCreator != nil { 24 logidCreator.Cleanup() 25 } 26 } 27 28 func SetLogLevel(newlv LogLevel) (oldlv LogLevel) { 29 return mylog.SetLogLevel(newlv) 30 } 31 32 func SetLogLevelByName(newlv string) (oldlv string) { 33 return mylog.SetLogLevelByName(newlv) 34 } 35 36 func PrintPretty(prefix string, v interface{}) { 37 mylog.PrintPretty(prefix, v) 38 } 39 40 func DebugfWithDepth(calldepth int, format string, v ...interface{}) { 41 mylog.DebugfWithDepth(calldepth, format, v...) 42 } 43 44 func Debugf(format string, v ...interface{}) { 45 mylog.Debugf(format, v...) 46 } 47 48 func Noticef(format string, v ...interface{}) { 49 mylog.Noticef(format, v...) 50 } 51 52 func NoticefWithDepth(calldepth int, format string, v ...interface{}) { 53 mylog.NoticefWithDepth(calldepth, format, v...) 54 } 55 56 func Infof(format string, v ...interface{}) { 57 mylog.Infof(format, v...) 58 } 59 60 func Warningf(format string, v ...interface{}) { 61 mylog.Warningf(format, v...) 62 } 63 64 func Errorf(format string, v ...interface{}) { 65 mylog.Warningf(format, v...) 66 } 67 68 func Panicf(format string, v ...interface{}) { 69 mylog.Panicf(format, v...) 70 } 71 72 func Fatalf(format string, v ...interface{}) { 73 mylog.Fatalf(format, v...) 74 } 75 76 func TraceInto(format string, v ...interface{}) string { 77 _, fn, line, _ := runtime.Caller(1) 78 strfn := fmt.Sprintf("%s:%d", fn, line) 79 Debugf("TRACE into ["+strfn+"]"+format+"...\r\n", v...) 80 81 return strfn 82 } 83 84 func TraceExit(strfn string, format string, v ...interface{}) { 85 Debugf("TRACE exit ["+strfn+"]"+format+"...\r\n", v...) 86 } 87 88 func RegisterLogidCreator(idc LogidCreator) { 89 logidCreator = idc 90 SetLogid(fmt.Sprintf("sysinit(%d)", os.Getpid())) 91 }