mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-10 18:40:53 +00:00
Logging
This commit is contained in:
parent
8a86f57304
commit
50919133ac
6 changed files with 64 additions and 5 deletions
22
radicale/log.py
Normal file
22
radicale/log.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging, sys
|
||||
from radicale import config
|
||||
|
||||
class log:
|
||||
def __init__(self):
|
||||
self.logger=logging.getLogger("radicale")
|
||||
self.logger.setLevel(config.get("logging", "facility"))
|
||||
|
||||
handler=logging.FileHandler(config.get("logging", "logfile"))
|
||||
|
||||
formatter = logging.Formatter('%(name)s %(asctime)s %(levelname)s %(message)s')
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
self.logger.addHandler(handler)
|
||||
def log(self, level, msg):
|
||||
self.logger.log(level, msg)
|
||||
|
||||
_LOGGING = log()
|
||||
|
||||
sys.modules[__name__] = _LOGGING
|
Loading…
Add table
Add a link
Reference in a new issue