Add class for logging in log file

This commit is contained in:
System User 2010-12-02 16:42:16 +01:00
parent 8a86f57304
commit 77ff57eb72

28
radicale/log.py Normal file
View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
import sys
import logging
from radicale import config
LEVELS = { 'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': logging.CRITICAL}
level=LEVELS.get(config.get("logging", "level"), logging.NOTSET)
logger=logging.getLogger("radicale")
logger.setLevel(level=level)
handler=logging.FileHandler(config.get("logging", "file"))
handler.setLevel(level=level)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
sys.modules[__name__] = logger