UIBase: add a syslog ui
Rather than having an option for syslog output, make a separate UI option. Signed-off-by: Ben Boeckel <mathstuf@gmail.com> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:

committed by
Nicolas Sebrecht

parent
3daddb9b33
commit
e18428b25b
@ -17,6 +17,7 @@
|
||||
|
||||
import logging
|
||||
from offlineimap.ui.UIBase import UIBase
|
||||
import offlineimap
|
||||
|
||||
class Basic(UIBase):
|
||||
"""'Basic' simply sets log level to INFO"""
|
||||
@ -27,3 +28,22 @@ class Quiet(UIBase):
|
||||
"""'Quiet' simply sets log level to WARNING"""
|
||||
def __init__(self, config, loglevel = logging.WARNING):
|
||||
return super(Quiet, self).__init__(config, loglevel)
|
||||
|
||||
class Syslog(UIBase):
|
||||
"""'Syslog' sets log level to INFO and outputs to syslog instead of stdout"""
|
||||
def __init__(self, config, loglevel = logging.INFO):
|
||||
return super(Syslog, self).__init__(config, loglevel)
|
||||
|
||||
def setup_consolehandler(self):
|
||||
# create syslog handler
|
||||
ch = logging.handlers.SysLogHandler('/dev/log')
|
||||
# create formatter and add it to the handlers
|
||||
self.formatter = logging.Formatter("%(message)s")
|
||||
ch.setFormatter(self.formatter)
|
||||
# add the handlers to the logger
|
||||
self.logger.addHandler(ch)
|
||||
self.logger.info(offlineimap.banner)
|
||||
return ch
|
||||
|
||||
def setup_sysloghandler(self):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user