mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Logging to stdout, syslog or file
This commit is contained in:
parent
bb7f36fc59
commit
a4024f8183
3 changed files with 14 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging, sys
|
||||
from logging.handlers import SysLogHandler
|
||||
from radicale import config
|
||||
|
||||
class log:
|
||||
|
@ -8,8 +9,14 @@ class log:
|
|||
self.logger=logging.getLogger("radicale")
|
||||
self.logger.setLevel(config.get("logging", "facility"))
|
||||
|
||||
handler=logging.FileHandler(config.get("logging", "logfile"))
|
||||
|
||||
loggingType=config.get("logging", "type")
|
||||
if loggingType == "stdout":
|
||||
handler=logging.StreamHandler(sys.stdout)
|
||||
elif loggingType == "file":
|
||||
handler=logging.FileHandler(config.get("logging", "logfile"))
|
||||
else:
|
||||
handler=logging.handlers.SysLogHandler("/dev/log")
|
||||
|
||||
formatter = logging.Formatter('%(name)s %(asctime)s %(levelname)s %(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue