Skip to content

Commit 476a93a

Browse files
authored
Merge pull request #9 from DragonFlyBSD/log-fullpath
chore: Update log to print with full file path
2 parents 73736d7 + a1649ff commit 476a93a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

common/log.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,23 @@ var (
1515
)
1616

1717
func init() {
18-
flag := log.Ldate|log.Ltime
18+
flag := log.Ldate | log.Ltime
1919
outLogger = log.New(os.Stdout, "", flag)
2020
errLogger = log.New(os.Stderr, "", flag)
2121
}
2222

2323
// Get the file and function information of the logger caller.
24-
// Result: "filename:line:function"
24+
// Result: "file:line:function"
2525
func getOrigin() string {
2626
// calldepth is 2: caller -> xxxPrintf() -> getOrigin()
2727
pc, file, line, ok := runtime.Caller(2)
2828
if !ok {
29-
return "???:0:???"
29+
return "???:?:???"
3030
}
3131

32-
filename := file[strings.LastIndex(file, "/")+1:]
3332
funcname := runtime.FuncForPC(pc).Name()
3433
fn := funcname[strings.LastIndex(funcname, ".")+1:]
35-
return filename + ":" + strconv.Itoa(line) + ":" + fn
34+
return file + ":" + strconv.Itoa(line) + ":" + fn
3635
}
3736

3837
func DebugPrintf(format string, v ...interface{}) {

0 commit comments

Comments
 (0)