mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 14:22:04 +08:00
log: add Stack() function for debugging who calls what
This commit is contained in:
parent
b242b0a078
commit
557edecd40
|
@ -65,6 +65,18 @@ func Trace(o interface{}, format string, a ...interface{}) func(string, ...inter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stack logs a stack trace of callers with the o and info passed in
|
||||||
|
func Stack(o interface{}, info string) {
|
||||||
|
if fs.Config.LogLevel < fs.LogLevelDebug {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
arr := [16 * 1024]byte{}
|
||||||
|
buf := arr[:]
|
||||||
|
n := runtime.Stack(buf, false)
|
||||||
|
buf = buf[:n]
|
||||||
|
fs.LogPrintf(fs.LogLevelDebug, o, "%s\nStack trace:\n%s", info, buf)
|
||||||
|
}
|
||||||
|
|
||||||
// InitLogging start the logging as per the command line flags
|
// InitLogging start the logging as per the command line flags
|
||||||
func InitLogging() {
|
func InitLogging() {
|
||||||
flagsStr := "," + *logFormat + ","
|
flagsStr := "," + *logFormat + ","
|
||||||
|
|
Loading…
Reference in New Issue
Block a user