Changeset 2859 for pykota/trunk
- Timestamp:
- 04/10/06 11:30:00 (19 years ago)
- Location:
- pykota/trunk/pykota/loggers
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/loggers/stderr.py
r2622 r2859 23 23 # 24 24 25 """This module defines a class for PyKota logging through stderr.""" 26 25 27 import sys 26 28 import os 29 30 __revision__ = "$Id$" 27 31 28 32 class Logger : … … 31 35 """Sends the message to the appropriate logging subsystem.""" 32 36 try : 33 sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip())) 37 sys.stderr.write("%s: PyKota (PID %s) : %s\n" \ 38 % (level.upper(), \ 39 os.getpid(), \ 40 message.strip())) 34 41 except IOError : 35 42 pass # What else could we do ? -
pykota/trunk/pykota/loggers/system.py
r2622 r2859 23 23 # 24 24 25 """This module defines a class for PyKota logging through syslog.""" 26 25 27 import os 26 28 import syslog 27 29 30 __revision__ = "$Id$" 31 28 32 class Logger : 29 33 """A logger class which logs to syslog.""" 30 levels = { "error" : "ERR", "warn": "WARNING", "info": "INFO", "debug": "DEBUG" } 34 levels = { "error" : "ERR", "warn": "WARNING", \ 35 "info": "INFO", "debug": "DEBUG" } 31 36 def __init__(self) : 32 37 """Opens the logging subsystem.""" … … 39 44 def log_message(self, message, level="info") : 40 45 """Sends the message to syslog.""" 41 priority = getattr(syslog, "LOG_%s" % self.levels.get(level.lower(), "DEBUG").upper(), syslog.LOG_DEBUG) 42 try : 43 syslog.syslog(priority, "(PID %s) : %s" % (os.getpid(), message.strip())) 44 except : 45 pass # What else could we do ? 46 priority = getattr(syslog, \ 47 "LOG_%s" % self.levels.get(level.lower(), \ 48 "DEBUG").upper(), \ 49 syslog.LOG_DEBUG) 50 syslog.syslog(priority, "(PID %s) : %s" \ 51 % (os.getpid(), message.strip()))