From d0ff815234474b401f84bf7a95cffd0587fc439f Mon Sep 17 00:00:00 2001
From: nejucomo <nejucomo@gmail.com>
Date: Sat, 31 May 2008 19:22:18 -0700
Subject: [PATCH] fuse_a: logging: Make logging a bit cleaner, and make it log
 to the correct location!

---
 contrib/fuse_a/tahoe_fuse.py | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/contrib/fuse_a/tahoe_fuse.py b/contrib/fuse_a/tahoe_fuse.py
index 33d65bbc..71bcb169 100644
--- a/contrib/fuse_a/tahoe_fuse.py
+++ b/contrib/fuse_a/tahoe_fuse.py
@@ -79,21 +79,26 @@ def main():
             except IndexError:
                 sys.argv = [sys.argv[0], '--help']
                 
-    print 'DEBUG:', sys.argv
-            
+
+    log_init(basedir)
+    log('Commandline: %r', sys.argv)
+
     fs = TahoeFS(basedir)
     fs.main()
 
 
 ### Utilities for debug:
-_logfile = None
-def log(msg, *args):
+_logfile = None # Private to log* functions.
+
+def log_init(confdir):
     global _logfile
-    if _logfile is None:
-        confdir = os.path.expanduser(TahoeConfigDir)
-        path = os.path.join(confdir, 'logs', 'tahoe_fuse.log')
-        _logfile = open(path, 'a')
-        _logfile.write('Log opened at: %s\n' % (time.strftime('%Y-%m-%d %H:%M:%S'),))
+    
+    logpath = os.path.join(confdir, 'logs', 'tahoe_fuse.log')
+    _logfile = open(logpath, 'a')
+    log('Log opened at: %s\n', time.strftime('%Y-%m-%d %H:%M:%S'))
+
+
+def log(msg, *args):
     _logfile.write((msg % args) + '\n')
     _logfile.flush()
     
-- 
2.45.2