Przeglądaj źródła

fuse2: optimize/generalize debug and test logging

Thomas Waldmann 1 miesiąc temu
rodzic
commit
f545ebbf0d

+ 7 - 5
src/borg/fuse2.py

@@ -1,3 +1,4 @@
+import datetime
 import errno
 import hashlib
 import os
@@ -27,14 +28,15 @@ from .platformflags import is_darwin
 from .repository import Repository
 from .remote import RemoteRepository
 
+DEBUG_LOG = None  # os.path.join(os.getcwd(), "fuse_debug.log")
+
 
 def debug_log(msg):
     """Append debug message to fuse_debug.log"""
-    import datetime
-
-    timestamp = datetime.datetime.now().strftime("%H:%M:%S.%f")[:-3]
-    with open("/Users/tw/w/borg_ag/fuse_debug.log", "a") as f:
-        f.write(f"{timestamp} {msg}\n")
+    if DEBUG_LOG:
+        timestamp = datetime.datetime.now().strftime("%H:%M:%S.%f")[:-3]
+        with open(DEBUG_LOG, "a") as f:
+            f.write(f"{timestamp} {msg}\n")
 
 
 def fuse_main():

+ 1 - 1
src/borg/testsuite/archiver/mount2_cmds_test.py

@@ -119,7 +119,7 @@ def fuse_mount2(archiver, mountpoint, *args, **kwargs):
     # For debugging, let's inherit stderr
     # p = subprocess.Popen(full_cmd, env=env, stdout=subprocess.PIPE, stderr=None)
 
-    log_file_path = "/Users/tw/w/borg_ag/mount2.log"
+    log_file_path = os.path.join(os.getcwd(), "mount2.log")
     log_file = open(log_file_path, "w")
     p = subprocess.Popen(full_cmd, env=env, stdout=log_file, stderr=log_file)