summaryrefslogtreecommitdiffstats
path: root/pykolab/logger.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-02-21 15:14:28 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-02-21 15:14:28 +0000
commitb72a83b79a3616a0c451143f66332876929aee2b (patch)
tree285eb022fe671d23126a7f4530d6c4a66a92543a /pykolab/logger.py
parent8a85a51fb60d01495ed470bd1e545d98c05b1299 (diff)
downloadpykolab-b72a83b79a3616a0c451143f66332876929aee2b.tar.gz
Update pykolab including:
- a plugin system, - some example plugins, - a working kolab daemon, - copyright updates, - auth/ldap/ abstraction so auth/sql/ can be plugged in, - and more.
Diffstat (limited to 'pykolab/logger.py')
-rw-r--r--pykolab/logger.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/pykolab/logger.py b/pykolab/logger.py
index e6d5a91..48c840d 100644
--- a/pykolab/logger.py
+++ b/pykolab/logger.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright 2010 Kolab Systems AG (http://www.kolabsys.com)
+# Copyright 2010-2011 Kolab Systems AG (http://www.kolabsys.com)
#
# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
#
@@ -26,13 +26,14 @@ from pykolab.translate import _, N_
class Logger:
def __init__(self, loglevel=logging.INFO, debuglevel=0, logfile="/var/log/kolab/kolabd.log"):
+
self.loglevel = loglevel
self.debuglevel = debuglevel
plaintextformatter = logging.Formatter("%(message)s")
- console_stdout = logging.StreamHandler(sys.stdout)
- console_stdout.setFormatter(plaintextformatter)
+ self.console_stdout = logging.StreamHandler(sys.stdout)
+ self.console_stdout.setFormatter(plaintextformatter)
try:
filelog_handler = logging.FileHandler(filename=logfile)
@@ -40,14 +41,19 @@ class Logger:
except IOError, e:
print >> sys.stderr, _("Cannot log to file %s: %s") % (logfile, e)
- self.log = logging.getLogger()
- self.log.addHandler(console_stdout)
- try:
- self.log.addHandler(filelog_handler)
- except:
- pass
+ self.log = logging.getLogger('pykolab')
+
+ if not len(self.log.handlers) > 1:
+ self.log.addHandler(self.console_stdout)
+ try:
+ self.log.addHandler(filelog_handler)
+ except:
+ pass
+
+ self.log.setLevel(self.loglevel)
- self.log.setLevel(self.loglevel)
+ def remove_stdout_handler(self):
+ self.log.removeHandler(self.console_stdout)
def set_config(self, cfg):
"""Let the Logger instance know what our configuration is and she might