From 55d67e629d5839182cfd3a07f8a20622cfc13d56 Mon Sep 17 00:00:00 2001 From: System User Date: Thu, 23 Dec 2010 10:06:37 +0100 Subject: [PATCH 1/2] Logging --- radicale/__init__.py | 2 +- radicale/xmlutils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 2fc3f80..8461f9c 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -46,7 +46,7 @@ except ImportError: import BaseHTTPServer as server # pylint: enable=F0401 -from radicale import acl, config, ical, xmlutils +from radicale import acl, config, ical, xmlutils, log VERSION = "git" diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index b49666c..9f05721 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -84,7 +84,7 @@ def propfind(path, xml_request, calendar, depth, request): """Read and answer PROPFIND requests. Read rfc4918-9.1 for info. - + """ # Reading request root = ET.fromstring(xml_request) @@ -138,7 +138,7 @@ def propfind(path, xml_request, calendar, depth, request): elif tag == _tag("D", "getcontenttype"): element.text = "text/calendar" elif tag == _tag("D", "getetag"): - element.text = element.etag + element.text = element.tag elif tag == _tag("D", "displayname"): element.text = calendar.name elif tag == _tag("D", "supported-report-set"): From a4024f81831caddd652d0615f21552c9fd8cac17 Mon Sep 17 00:00:00 2001 From: System User Date: Tue, 22 Feb 2011 15:46:42 +0100 Subject: [PATCH 2/2] Logging to stdout, syslog or file --- config | 5 ++++- radicale/config.py | 2 +- radicale/log.py | 11 +++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config b/config index b1ee131..6380a7f 100644 --- a/config +++ b/config @@ -53,7 +53,10 @@ LDAPAppend = ou=users,dc=exmaple,dc=dom folder = ~/.config/radicale/calendars [Logging] -# Logging filename +# Logging type +# Value: syslog | file | stdout +type = file +# Logging filename (if needed) logfile = ~/.config/radicale/radicale.log # Log facility 10: DEBUG, 20: INFO, 30 WARNING, 40 ERROR, 50 CRITICAL facility = 50 diff --git a/radicale/config.py b/radicale/config.py index 74a315e..17735a0 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -56,7 +56,7 @@ INITIAL_CONFIG = { "storage": { "folder": os.path.expanduser("~/.config/radicale/calendars")}, "logging": { - "logfile": os.path.expanduser("~/.config/radicale/radicale.log"), + "type": "syslog", "facility": 10}, "authLdap": { "LDAPServer": "127.0.0.1", diff --git a/radicale/log.py b/radicale/log.py index 072857a..2692a7e 100644 --- a/radicale/log.py +++ b/radicale/log.py @@ -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)