merging with geni-api branch
[sfa.git] / sfa / util / sfalogging.py
index ff08c08..0e17ccb 100644 (file)
@@ -1,17 +1,20 @@
 import logging
+import os
 
 #SFA access log initialization
-
+TMPDIR = os.getenv("TMPDIR", "/tmp")
+SFA_HTTPD_ACCESS_LOGFILE = TMPDIR + "/" + 'sfa_httpd_access.log'
 SFA_ACCESS_LOGFILE='/var/log/sfa_access.log'
-SFA_HTTPD_ACCESS_LOGFILE='/tmp/sfa_httpd_access.log'
 logger=logging.getLogger()
 logger.setLevel(logging.INFO)
+
 try:
-     logfile=logging.FileHandler(SFA_ACCESS_LOGFILE)
+    logfile=logging.FileHandler(SFA_ACCESS_LOGFILE)
 except IOError:
-     # This is usually a permissions error becaue the file is
-     # owned by root, but httpd is trying to access it.
-     logfile=logging.FileHandler(SFA_HTTPD_ACCESS_LOGFILE)
+    # This is usually a permissions error becaue the file is
+    # owned by root, but httpd is trying to access it.
+    logfile=logging.FileHandler(SFA_HTTPD_ACCESS_LOGFILE)
+    
 formatter = logging.Formatter("%(asctime)s - %(message)s")
 logfile.setFormatter(formatter)
 logger.addHandler(logfile)