File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 22package log
33
44import (
5+ "fmt"
56 "log"
67 "os"
8+ "runtime"
79)
810
911var (
1315
1416func init () {
1517 InfoLog = log .New (os .Stdout , "" , log .Ldate | log .Ltime )
16- ErrorLog = log .New (os .Stderr , "ERROR: " , log .Ldate | log .Ltime | log . Lshortfile )
18+ ErrorLog = log .New (os .Stderr , "ERROR: " , log .Ldate | log .Ltime )
1719}
1820
1921// Info logs an informational message to Stdout.
@@ -23,5 +25,18 @@ func Info(s string, v ...interface{}) {
2325
2426// Error logs an error to Stderr.
2527func Error (s string , v ... interface {}) {
26- ErrorLog .Printf (s , v ... )
28+ // Include original caller information
29+ _ , file , line , _ := runtime .Caller (1 )
30+
31+ // Determine short filename (from standard log package)
32+ short := file
33+ for i := len (file ) - 1 ; i > 0 ; i -- {
34+ if file [i ] == '/' {
35+ short = file [i + 1 :]
36+ break
37+ }
38+ }
39+ file = short
40+
41+ ErrorLog .Printf (fmt .Sprintf ("%s:%d: " , short , line )+ s , v ... )
2742}
You can’t perform that action at this time.
0 commit comments