5 #SFA access log initialization
6 TMPDIR = os.getenv("TMPDIR", "/tmp")
7 SFA_HTTPD_ACCESS_LOGFILE = TMPDIR + "/" + 'sfa_httpd_access.log'
8 SFA_ACCESS_LOGFILE='/var/log/sfa_access.log'
9 logger=logging.getLogger()
10 #logger.setLevel(logging.INFO)
11 logger.setLevel(logging.DEBUG)
14 logfile=logging.FileHandler(SFA_ACCESS_LOGFILE)
16 # This is usually a permissions error becaue the file is
17 # owned by root, but httpd is trying to access it.
18 logfile=logging.FileHandler(SFA_HTTPD_ACCESS_LOGFILE)
20 formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
21 logfile.setFormatter(formatter)
22 logger.addHandler(logfile)
26 # logs an exception - use in an except statement
28 logger.error("%s BEG TRACEBACK"%message+"\n"+traceback.format_exc().strip("\n"))
29 logger.error("%s END TRACEBACK"%message)
32 # for investigation purposes, can be placed anywhere
33 def log_stack(message):
34 to_log="".join(traceback.format_stack())
35 logger.debug("%s BEG STACK"%message+"\n"+to_log)
36 logger.debug("%s END STACK"%message)