Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/bin/test_server.py

Issue 5076874740891648: Issue 2456 - [cms] Use logging module (Closed)
Patch Set: Created May 5, 2015, 1:30 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cms/bin/generate_static_pages.py ('k') | cms/sources.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/bin/test_server.py
===================================================================
--- a/cms/bin/test_server.py
+++ b/cms/bin/test_server.py
@@ -106,9 +106,20 @@
try:
from werkzeug.serving import run_simple
+ def run(*args, **kwargs):
+ # The werkzeug logger must be configured before the
+ # root logger. Also we must prevent it from propagating
+ # messages, otherwise messages are logged twice.
+ import logging
+ logger = logging.getLogger("werkzeug")
+ logger.propagate = False
+ logger.setLevel(logging.INFO)
+ logger.addHandler(logging.StreamHandler())
+
+ run_simple(*args, **kwargs)
except ImportError:
from wsgiref.simple_server import make_server
- def run_simple(host, port, app, **kwargs):
+ def run(host, port, app, **kwargs):
def wrapper(environ, start_response):
try:
return app(environ, start_response)
@@ -120,4 +131,4 @@
print " * Running on http://%s:%i/" % server.server_address
server.serve_forever()
- run_simple("localhost", 5000, handler, use_reloader=True, use_debugger=True)
+ run("localhost", 5000, handler, use_reloader=True, use_debugger=True)
« no previous file with comments | « cms/bin/generate_static_pages.py ('k') | cms/sources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld