[prev in list] [next in list] [prev in thread] [next in thread]
List: calendarserver-changes
Subject: [CalendarServer-changes] [2352]
From: source_changes () macosforge ! org
Date: 2008-04-26 0:26:51
Message-ID: 20080426002651.9E6E815EB110 () beta ! macosforge ! org
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Revision: 2352
http://trac.macosforge.org/projects/calendarserver/changeset/2352
Author: wsanchez@apple.com
Date: 2008-04-25 17:26:51 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Set log levels in config.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist
CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py
Modified: CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist 2008-04-26 \
00:26:51 UTC (rev 2352) @@ -250,6 +250,14 @@
<key>ErrorLogFile</key>
<string>logs/error.log</string>
+ <!-- Log Levels -->
+ <key>DefaultLogLevel</key>
+ <string>info</string> <!-- debug, info, warn, error -->
+
+ <key>LogLevels</key>
+ <dict>
+ </dict>
+
<!-- Server statistics file -->
<key>ServerStatsFile</key>
<string>logs/stats.plist</string>
Modified: CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist
===================================================================
--- CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist 2008-04-26 \
00:26:51 UTC (rev 2352) @@ -202,6 +202,10 @@
<key>ErrorLogFile</key>
<string>/var/log/caldavd/error.log</string>
+ <!-- Log Levels -->
+ <key>DefaultLogLevel</key>
+ <string>info</string> <!-- debug, info, warn, error -->
+
<!-- Server statistics file -->
<key>ServerStatsFile</key>
<string>/var/run/caldavd/stats.plist</string>
Modified: CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py
===================================================================
--- CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py 2008-04-26 \
00:26:51 UTC (rev 2352) @@ -20,6 +20,7 @@
from twistedcaldav.py.plistlib import readPlist
from twistedcaldav.log import Logger
+from twistedcaldav.log import clearLogLevels, setLogLevelForNamespace, \
InvalidLogLevelError
log = Logger()
@@ -91,8 +92,8 @@
# Authentication
#
"Authentication": {
- "Basic" : { "Enabled": False }, # Clear text; best avoided
- "Digest" : { # Digest challenge/response
+ "Basic": { "Enabled": False }, # Clear text; best avoided
+ "Digest": { # Digest challenge/response
"Enabled": True,
"Algorithm": "md5",
"Qop": "",
@@ -107,11 +108,13 @@
# Logging
#
"Verbose": False,
- "AccessLogFile" : "/var/log/caldavd/access.log", # \
Apache-style access log
- "ErrorLogFile" : "/var/log/caldavd/error.log", # Server \
activity log + "AccessLogFile" : "/var/log/caldavd/access.log", # Apache-style \
access log + "ErrorLogFile" : "/var/log/caldavd/error.log", # Server activity \
log "ServerStatsFile": "/var/run/caldavd/stats.plist",
"PIDFile" : "/var/run/caldavd.pid",
"RotateAccessLog": False,
+ "DefaultLogLevel": None,
+ "LogLevels": {},
#
# SSL/TLS
@@ -220,20 +223,32 @@
if param not in \
serviceDefaultParams[self._data["DirectoryService"]["type"]]: del \
self._data["DirectoryService"]["params"][param]
- self.updateServerCapabilities()
-
- def updateServerCapabilities(self):
- """
- Change server capabilities based on the current config parameters.
- Here are the "features" in the config that need special treatment:
-
- EnableDropBox
- EnableNotifications
- """
+ #
+ # FIXME: Use the config object instead of doing this here
+ #
from twistedcaldav.resource import CalendarPrincipalResource
CalendarPrincipalResource.enableDropBox(self.EnableDropBox)
CalendarPrincipalResource.enableNotifications(self.EnableNotifications)
+ self.updateLogLevels()
+
+ def updateLogLevels(self):
+ clearLogLevels()
+
+ try:
+ if "DefaultLogLevel" in self._data:
+ level = self._data["DefaultLogLevel"]
+ if not level:
+ level = "info"
+ setLogLevelForNamespace(None, level)
+
+ if "LogLevels" in self._data:
+ for namespace in self._data["LogLevels"]:
+ setLogLevelForNamespace(namespace, \
self._data["LogLevels"][namespace]) +
+ except InvalidLogLevelError, e:
+ raise ConfigurationError("Invalid log level: %s" % (e.level))
+
def updateDefaults(self, items):
_mergeData(self._defaults, items)
self.update(items)
@@ -242,7 +257,7 @@
self._defaults = copy.deepcopy(defaults)
def __setattr__(self, attr, value):
- if '_data' in self.__dict__ and attr in self.__dict__['_data']:
+ if "_data" in self.__dict__ and attr in self.__dict__["_data"]:
self._data[attr] = value
else:
self.__dict__[attr] = value
Modified: CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py
===================================================================
--- CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py 2008-04-26 \
00:26:51 UTC (rev 2352) @@ -17,7 +17,7 @@
from twisted.trial import unittest
from twistedcaldav.py.plistlib import writePlist
-
+from twistedcaldav.log import logLevelForNamespace
from twistedcaldav.config import config, defaultConfig, ConfigurationError
from twistedcaldav.static import CalDAVFile
@@ -25,10 +25,21 @@
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0">
<dict>
+
<key>Verbose</key>
<true/>
+
<key>HTTPPort</key>
<integer>8008</integer>
+
+ <key>DefaultLogLevel</key>
+ <string>warn</string>
+ <key>LogLevels</key>
+ <dict>
+ <key>some.namespace</key>
+ <string>debug</string>
+ </dict>
+
</dict>
</plist>
"""
@@ -214,7 +225,6 @@
self.assertNotIn('Foo', defaultConfig)
def testComplianceClasses(self):
-
resource = CalDAVFile("/")
config.EnableProxyPrincipals = True
@@ -222,3 +232,21 @@
config.EnableProxyPrincipals = False
self.assertTrue("calendar-proxy" not in resource.davComplianceClasses())
+
+ def test_logging(self):
+ """
+ Logging module configures properly.
+ """
+ self.assertEquals(logLevelForNamespace(None), "info")
+ self.assertEquals(logLevelForNamespace("some.namespace"), "info")
+
+ config.loadConfig(self.testConfig)
+
+ self.assertEquals(logLevelForNamespace(None), "warn")
+ self.assertEquals(logLevelForNamespace("some.namespace"), "debug")
+
+ writePlist({}, self.testConfig)
+ config.reload()
+
+ self.assertEquals(logLevelForNamespace(None), "info")
+ self.assertEquals(logLevelForNamespace("some.namespace"), "info")
[Attachment #5 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style \
type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: \
6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; \
padding: 6px; } #msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<title>[2352] CalendarServer/branches/users/wsanchez/logging</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a \
href="http://trac.macosforge.org/projects/calendarserver/changeset/2352">2352</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2008-04-25 17:26:51 -0700 (Fri, 25 Apr 2008)</dd>
</dl>
<h3>Log Message</h3>
<pre>Set log levels in config.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserswsanchezloggingconfcaldavdtestplist">CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist</a></li>
<li><a href="#CalendarServerbranchesuserswsanchezloggingconfcaldavdplist">CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist</a></li>
<li><a href="#CalendarServerbranchesuserswsanchezloggingtwistedcaldavconfigpy">CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py</a></li>
<li><a href="#CalendarServerbranchesuserswsanchezloggingtwistedcaldavtesttest_configp \
y">CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserswsanchezloggingconfcaldavdtestplist"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist (2351 => \
2352)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/conf/caldavd-test.plist 2008-04-26 \
00:26:51 UTC (rev 2352) </span><span class="lines">@@ -250,6 +250,14 @@
</span><span class="cx"> <key>ErrorLogFile</key>
</span><span class="cx"> <string>logs/error.log</string>
</span><span class="cx">
</span><ins>+ <!-- Log Levels -->
+ <key>DefaultLogLevel</key>
+ <string>info</string> <!-- debug, info, warn, error -->
+
+ <key>LogLevels</key>
+ <dict>
+ </dict>
+
</ins><span class="cx"> <!-- Server statistics file -->
</span><span class="cx"> <key>ServerStatsFile</key>
</span><span class="cx"> <string>logs/stats.plist</string>
</span></span></pre></div>
<a id="CalendarServerbranchesuserswsanchezloggingconfcaldavdplist"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist (2351 => 2352)</h4> \
<pre class="diff"><span> <span class="info">--- \
CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist 2008-04-26 00:24:43 \
UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/conf/caldavd.plist 2008-04-26 \
00:26:51 UTC (rev 2352) </span><span class="lines">@@ -202,6 +202,10 @@
</span><span class="cx"> <key>ErrorLogFile</key>
</span><span class="cx"> <string>/var/log/caldavd/error.log</string>
</span><span class="cx">
</span><ins>+ <!-- Log Levels -->
+ <key>DefaultLogLevel</key>
+ <string>info</string> <!-- debug, info, warn, error -->
+
</ins><span class="cx"> <!-- Server statistics file -->
</span><span class="cx"> <key>ServerStatsFile</key>
</span><span class="cx"> <string>/var/run/caldavd/stats.plist</string>
</span></span></pre></div>
<a id="CalendarServerbranchesuserswsanchezloggingtwistedcaldavconfigpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py (2351 => \
2352)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/twistedcaldav/config.py 2008-04-26 \
00:26:51 UTC (rev 2352) </span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx">
</span><span class="cx"> from twistedcaldav.py.plistlib import readPlist
</span><span class="cx"> from twistedcaldav.log import Logger
</span><ins>+from twistedcaldav.log import clearLogLevels, setLogLevelForNamespace, \
InvalidLogLevelError </ins><span class="cx">
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="lines">@@ -91,8 +92,8 @@
</span><span class="cx"> # Authentication
</span><span class="cx"> #
</span><span class="cx"> "Authentication": {
</span><del>- "Basic" : { "Enabled": False }, # Clear \
text; best avoided
- "Digest" : { # Digest challenge/response
</del><ins>+ "Basic": { "Enabled": False }, # Clear \
text; best avoided + "Digest": { # Digest \
challenge/response </ins><span class="cx"> "Enabled": True,
</span><span class="cx"> "Algorithm": "md5",
</span><span class="cx"> "Qop": "",
</span><span class="lines">@@ -107,11 +108,13 @@
</span><span class="cx"> # Logging
</span><span class="cx"> #
</span><span class="cx"> "Verbose": False,
</span><del>- "AccessLogFile" : \
"/var/log/caldavd/access.log", # \
Apache-style access log
- "ErrorLogFile" : "/var/log/caldavd/error.log", \
# Server activity log </del><ins>+ "AccessLogFile" : \
"/var/log/caldavd/access.log", # Apache-style access log + \
"ErrorLogFile" : "/var/log/caldavd/error.log", # Server \
activity log </ins><span class="cx"> "ServerStatsFile": \
"/var/run/caldavd/stats.plist", </span><span class="cx"> \
"PIDFile" : "/var/run/caldavd.pid", </span><span \
class="cx"> "RotateAccessLog": False, </span><ins>+ \
"DefaultLogLevel": None, + "LogLevels": {},
</ins><span class="cx">
</span><span class="cx"> #
</span><span class="cx"> # SSL/TLS
</span><span class="lines">@@ -220,20 +223,32 @@
</span><span class="cx"> if param not in \
serviceDefaultParams[self._data["DirectoryService"]["type"]]: \
</span><span class="cx"> del \
self._data["DirectoryService"]["params"][param] </span><span \
class="cx"> </span><del>- self.updateServerCapabilities()
-
- def updateServerCapabilities(self):
- """
- Change server capabilities based on the current config parameters.
- Here are the "features" in the config that need special treatment:
-
- EnableDropBox
- EnableNotifications
- """
</del><ins>+ #
+ # FIXME: Use the config object instead of doing this here
+ #
</ins><span class="cx"> from twistedcaldav.resource import \
CalendarPrincipalResource </span><span class="cx"> \
CalendarPrincipalResource.enableDropBox(self.EnableDropBox) </span><span class="cx"> \
CalendarPrincipalResource.enableNotifications(self.EnableNotifications) </span><span \
class="cx"> </span><ins>+ self.updateLogLevels()
+
+ def updateLogLevels(self):
+ clearLogLevels()
+
+ try:
+ if "DefaultLogLevel" in self._data:
+ level = self._data["DefaultLogLevel"]
+ if not level:
+ level = "info"
+ setLogLevelForNamespace(None, level)
+
+ if "LogLevels" in self._data:
+ for namespace in self._data["LogLevels"]:
+ setLogLevelForNamespace(namespace, \
self._data["LogLevels"][namespace]) +
+ except InvalidLogLevelError, e:
+ raise ConfigurationError("Invalid log level: %s" % (e.level))
+
</ins><span class="cx"> def updateDefaults(self, items):
</span><span class="cx"> _mergeData(self._defaults, items)
</span><span class="cx"> self.update(items)
</span><span class="lines">@@ -242,7 +257,7 @@
</span><span class="cx"> self._defaults = copy.deepcopy(defaults)
</span><span class="cx">
</span><span class="cx"> def __setattr__(self, attr, value):
</span><del>- if '_data' in self.__dict__ and attr in self.__dict__['_data']:
</del><ins>+ if "_data" in self.__dict__ and attr in \
self.__dict__["_data"]: </ins><span class="cx"> \
self._data[attr] = value </span><span class="cx"> else:
</span><span class="cx"> self.__dict__[attr] = value
</span></span></pre></div>
<a id="CalendarServerbranchesuserswsanchezloggingtwistedcaldavtesttest_configpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py \
(2351 => 2352)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py 2008-04-26 \
00:24:43 UTC (rev 2351)
+++ CalendarServer/branches/users/wsanchez/logging/twistedcaldav/test/test_config.py 2008-04-26 \
00:26:51 UTC (rev 2352) </span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx"> from twisted.trial import unittest
</span><span class="cx">
</span><span class="cx"> from twistedcaldav.py.plistlib import writePlist
</span><del>-
</del><ins>+from twistedcaldav.log import logLevelForNamespace
</ins><span class="cx"> from twistedcaldav.config import config, defaultConfig, \
ConfigurationError </span><span class="cx"> from twistedcaldav.static import \
CalDAVFile </span><span class="cx">
</span><span class="lines">@@ -25,10 +25,21 @@
</span><span class="cx"> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST \
1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> \
</span><span class="cx"> <plist version="1.0"> </span><span \
class="cx"> <dict> </span><ins>+
</ins><span class="cx"> <key>Verbose</key>
</span><span class="cx"> <true/>
</span><ins>+
</ins><span class="cx"> <key>HTTPPort</key>
</span><span class="cx"> <integer>8008</integer>
</span><ins>+
+ <key>DefaultLogLevel</key>
+ <string>warn</string>
+ <key>LogLevels</key>
+ <dict>
+ <key>some.namespace</key>
+ <string>debug</string>
+ </dict>
+
</ins><span class="cx"> </dict>
</span><span class="cx"> </plist>
</span><span class="cx"> """
</span><span class="lines">@@ -214,7 +225,6 @@
</span><span class="cx"> self.assertNotIn('Foo', defaultConfig)
</span><span class="cx">
</span><span class="cx"> def testComplianceClasses(self):
</span><del>-
</del><span class="cx"> resource = CalDAVFile("/")
</span><span class="cx">
</span><span class="cx"> config.EnableProxyPrincipals = True
</span><span class="lines">@@ -222,3 +232,21 @@
</span><span class="cx">
</span><span class="cx"> config.EnableProxyPrincipals = False
</span><span class="cx"> self.assertTrue("calendar-proxy" not in \
resource.davComplianceClasses()) </span><ins>+
+ def test_logging(self):
+ """
+ Logging module configures properly.
+ """
+ self.assertEquals(logLevelForNamespace(None), "info")
+ self.assertEquals(logLevelForNamespace("some.namespace"), \
"info") +
+ config.loadConfig(self.testConfig)
+
+ self.assertEquals(logLevelForNamespace(None), "warn")
+ self.assertEquals(logLevelForNamespace("some.namespace"), \
"debug") +
+ writePlist({}, self.testConfig)
+ config.reload()
+
+ self.assertEquals(logLevelForNamespace(None), "info")
+ self.assertEquals(logLevelForNamespace("some.namespace"), \
"info") </ins></span></pre>
</div>
</div>
</body>
</html>
_______________________________________________
calendarserver-changes mailing list
calendarserver-changes@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo/calendarserver-changes
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic