diff options
author | James Vasile <james@hackervisions.org> | 2011-02-22 13:32:45 -0500 |
---|---|---|
committer | James Vasile <james@hackervisions.org> | 2011-02-22 13:32:45 -0500 |
commit | 35071d7212cec1fc23e8204bfd392a116a5313ed (patch) | |
tree | 1c75a525227769fc94f303b5c0233882d90ef2a8 /logger.py |
...
Diffstat (limited to 'logger.py')
-rw-r--r-- | logger.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/logger.py b/logger.py new file mode 100644 index 0000000..6fd8171 --- /dev/null +++ b/logger.py @@ -0,0 +1,39 @@ +import cherrypy +import inspect +import cfg + +cherrypy.log.error_file = cfg.status_log_file +cherrypy.log.access_file = cfg.access_log_file +cherrypy.log.screen = False + +class Logger(): + """By convention, log levels are DEBUG, INFO, WARNING, ERROR and CRITICAL.""" + def log(self, msg, level="DEBUG"): + try: + username = cherrypy.session.get(cfg.session_key) + except AttributeError: + username = '' + cherrypy.log.error("%s %s %s" % (username, level, msg), inspect.stack()[2][3], 20) + def __call__(self, *args): + self.log(*args) + + def debug(self, msg): + self.log(msg) + + def info(self, msg): + self.log(msg, "INFO") + + def warn(self, msg): + self.log(msg, "WARNING") + + def warning(self, msg): + self.log(msg, "WARNING") + + def error(self, msg): + self.log(msg, "ERROR") + + def err(self, msg): + self.error(msg) + + def critical(self, msg): + self.log(msg, "CRITICAL") |