changeset 4251:3c6e893424f6

Fixed: log format and line-doubling in standalone server
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sun, 27 Jul 2008 17:40:11 +0200
parents 43da090ab838
children c2ee4633b9e8
files MoinMoin/web/serving.py MoinMoin/wsgiapp.py
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/web/serving.py	Sun Jul 27 17:40:11 2008 +0200
@@ -0,0 +1,30 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - This module contains additional code related to serving
+               requests with the standalone server. It uses werkzeug's
+               BaseRequestHandler and overrides some functions that
+               need to be handled different in MoinMoin than in werkzeug
+
+    @copyright: 2008-2008 MoinMoin:FlorianKrupicka
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from werkzeug.serving import BaseRequestHandler
+
+from MoinMoin import version, log
+logging = log.getLogger(__name__)
+
+class RequestHandler(BaseRequestHandler):
+    server_version = "MoinMoin %s %s" % (version.release,
+                                         version.revision)
+
+    # override the logging functions
+    def log_request(self, code='-', size='-'):
+        self.log_message('"%s" %s %s',
+                         self.requestline, code, size)
+
+    def log_error(self, format, *args):
+        self.log_message(format, *args)
+
+    def log_message(self, format, *args):
+        logging.info("%s %s", self.address_string(), (format % args))
--- a/MoinMoin/wsgiapp.py	Sun Jul 27 15:16:19 2008 +0200
+++ b/MoinMoin/wsgiapp.py	Sun Jul 27 17:40:11 2008 +0200
@@ -281,6 +281,7 @@
 def run_server(config):
     from os import path
     from MoinMoin.config import url_prefix_static
+    from MoinMoin.web.serving import RequestHandler
     from werkzeug.serving import run_simple
     from werkzeug.utils import SharedDataMiddleware
 
@@ -293,5 +294,6 @@
     params = {}
     params['use_debugger'] = config.debug
     params['threaded'] = True
+    params['request_handler'] = RequestHandler
 
     run_simple(config.interface, config.port, app, **params)