Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

log: add Stack() function for debugging who calls what

Nick Craig-Wood557edecd40e7
diff --git a/fs/log/log.go b/fs/log/log.go
index b38facb84..60e138dd8 100644
--- a/fs/log/log.go
+++ b/fs/log/log.go
@@ -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
func InitLogging() {
flagsStr := "," + *logFormat + ","