wangpl_study/day06/mylogger_test/mylogger.go

23 lines
332 B
Go
Raw Permalink Normal View History

2024-10-15 20:05:52 +08:00
package mylogger_test
2024-10-21 15:54:36 +08:00
import (
"fmt"
"path"
"runtime"
)
2024-10-15 20:05:52 +08:00
func main() {
}
2024-10-21 15:54:36 +08:00
func getInfo(skip int) (funcName, fileName string, lineNo int) {
pc, file, lineNo, ok := runtime.Caller(skip)
if !ok {
fmt.Printf("runtime.Caller() failed\n")
return
}
funcName = runtime.FunForPC(pc).Name()
fileName = path.Base(file)
return
2024-10-15 20:05:52 +08:00
}