我使用这样的全局记录器:
[root@dev log]# cat src/logging/logging.go
package logging
import (
"log"
"os"
)
var Logger *log.Logger
func init() {
Logger = log.New(os.Stdout, "[Debug]", log.Llongfile|log.LstdFlags)
}
func Debug(format string, v ...interface{}) {
Logger.SetPrefix("[Debug] ")
Logger.Printf(format, v...)
}
[root@dev log]# cat src/main/main.go
package main
import "logging"
func main() {
logging.Debug("in main")
}
在主函数中,我想得到:
[Debug] 2015/12/10 22:20:23 /tmp/log/src/main/main.go:6: in main
但我得到以下输出:
[Debug] 2015/12/10 22:20:23 /tmp/log/src/logging/logging.go:16: in main
如何获得调用记录器的正确文件?
摇曳的蔷薇
相关分类