diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2008-09-15 15:34:21 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2008-09-15 15:34:21 +0200 |
commit | 2a91802cafc270c0102cfd94a44d6831f65cb97a (patch) | |
tree | b22d1f3d3f37772e42ce262c377cb8341660df07 /portato/__init__.py | |
parent | adc195c45f67bb3da1b1e37fe6284a72c74f5c9d (diff) | |
download | portato-2a91802cafc270c0102cfd94a44d6831f65cb97a.tar.gz portato-2a91802cafc270c0102cfd94a44d6831f65cb97a.tar.bz2 portato-2a91802cafc270c0102cfd94a44d6831f65cb97a.zip |
Add a log-file
Diffstat (limited to '')
-rw-r--r-- | portato/__init__.py | 48 |
1 files changed, 4 insertions, 44 deletions
diff --git a/portato/__init__.py b/portato/__init__.py index b5a9859..5d5cb22 100644 --- a/portato/__init__.py +++ b/portato/__init__.py @@ -12,52 +12,12 @@ from __future__ import absolute_import -import logging -import sys -import os +from . import log -class OutputFormatter (logging.Formatter): - - colors = { - "blue" : 34, - "green" : 32, - "red" : 31, - "yellow": 33 - } - - def __init__(self, *args, **kwargs): - logging.Formatter.__init__(self, *args, **kwargs) - - for key, value in self.colors.iteritems(): - self.colors[key] = "\x1b[01;%02dm*\x1b[39;49;00m" % value - - def format (self, record): - string = logging.Formatter.format(self, record) - color = None - - if os.isatty(sys.stderr.fileno()): - if record.levelno <= logging.DEBUG: - color = self.colors["blue"] - elif record.levelno <= logging.INFO: - color = self.colors["green"] - elif record.levelno <= logging.WARNING: - color = self.colors["yellow"] - else: - color = self.colors["red"] - else: - color = "%s:" % record.levelname - - return "%s %s" % (color, string) - -# set the whole logging stuff -formatter = OutputFormatter("%(message)s (%(filename)s:%(lineno)s)") - -handler = logging.StreamHandler() -handler.setFormatter(formatter) -logging.getLogger("portatoLogger").addHandler(handler) -logging.getLogger("portatoLogger").setLevel(logging.DEBUG) -logging.getLogger("portatoLogger").propagate = False +# start logging +log.start(file=False) +# listener-handling __listener = None def get_listener(): |