[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r16886: {projects} Add timing information that is RFC 2822 compatible. It's an (projects/gettor)



Author: ioerror
Date: 2008-09-12 23:56:06 -0400 (Fri, 12 Sep 2008)
New Revision: 16886

Modified:
   projects/gettor/gettor_log.py
Log:
Add timing information that is RFC 2822 compatible. It's an email processing application after all!


Modified: projects/gettor/gettor_log.py
===================================================================
--- projects/gettor/gettor_log.py	2008-09-13 03:14:03 UTC (rev 16885)
+++ projects/gettor/gettor_log.py	2008-09-13 03:56:06 UTC (rev 16886)
@@ -9,6 +9,7 @@
 import os
 import sys
 #import threading
+from time import gmtime, strftime
 import ConfigParser
 import syslog
 from gettor_config import gettorConf
@@ -17,25 +18,27 @@
     '''
     A configurable logging system for gettor.
     '''
-    config  = gettorConf()
-    logger  = config.getLogSubSystem()
-    logfile = config.getLogFile()
-    logfd   = None
+    config    = gettorConf()
+    logger    = config.getLogSubSystem()
+    logfile   = config.getLogFile()
+    logfd     = None
+    pid       = str(os.getpid())
+    logPrefix = "gettor (pid " + pid + ") "
+
     # We can't get real shm ipc with python currently :-(
     #sem     = BoundedSemaphore(1)
 
     def _init_(self):  
-        print "gettor logger: ", logger
         # parse the configuration file so we know how we're running 
         if logger == "file":
             try:
                 self.logfd = open(logfile, "w+")
             except:
-                print "Could not open logfile", logfile
                 self.logfd = None
-            print "Logging to file"
     
     def log(self, message):
+        now = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
+        message = logPrefix + now + " : "+ message
         # Log the message
         if self.logger == "syslog":
             syslog.syslog(message)