← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:gunicorn-tidy-logging into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:gunicorn-tidy-logging into launchpad:master.

Commit message:
Tidy up gunicorn logging some more

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/404416

If we're using gunicorn, we don't want the extra ZConfig log handler; all the logging should go to Talisker's structured logger.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:gunicorn-tidy-logging into launchpad:master.
diff --git a/lib/lp/scripts/runlaunchpad.py b/lib/lp/scripts/runlaunchpad.py
index 61be72e..2c8b232 100644
--- a/lib/lp/scripts/runlaunchpad.py
+++ b/lib/lp/scripts/runlaunchpad.py
@@ -343,9 +343,15 @@ def gunicornify_zope_config_file():
         content = fd.read()
 
     # Remove unwanted tags.
-    for tag in ['server', 'accesslog']:
+    for tag in ['server', 'accesslog', 'logger']:
         content = re.sub(
-            r"<%s>(.*)</%s>" % (tag, tag), "", content, flags=re.S)
+            r"<%s>.*?</%s>" % (tag, tag), "", content, flags=re.S)
+
+    # Remove unwanted contents of required tags.
+    for tag in ['eventlog']:
+        content = re.sub(
+            r"<%s>.*?</%s>" % (tag, tag), "<%s>\n</%s>" % (tag, tag), content,
+            flags=re.S)
 
     # Remove unwanted single-line directives.
     for directive in ['interrupt-check-interval']:
diff --git a/lib/lp/scripts/tests/test_runlaunchpad.py b/lib/lp/scripts/tests/test_runlaunchpad.py
index 27d2051..15dbc5d 100644
--- a/lib/lp/scripts/tests/test_runlaunchpad.py
+++ b/lib/lp/scripts/tests/test_runlaunchpad.py
@@ -205,16 +205,32 @@ class TestAppServerStart(lp.testing.TestCase):
           type XXX
           address 123
         </server>
-        
+
         <zodb>
           <mappingstorage/>
         </zodb>
-        
+
         <accesslog>
           <logfile>
             path logs/test-appserver-layer.log
           </logfile>
         </accesslog>
+
+        <eventlog>
+          <logfile>
+            path logs/test-appserver-layer.log
+          </logfile>
+        </eventlog>
+
+        <logger>
+          name zc.tracelog
+          propagate false
+
+          <logfile>
+            format %(message)s
+            path logs/test-appserver-layer-trace.log
+          </logfile>
+        </logger>
         """)
         config_filename = tempfile.mktemp()
         with open(config_filename, "w") as fd:
@@ -233,12 +249,18 @@ class TestAppServerStart(lp.testing.TestCase):
                 site-definition zcml/webapp.zcml
                 # With some comment
                 devmode off
-                
-                
-                
+
+
+
+
                 <zodb>
                   <mappingstorage/>
                 </zodb>
 
 
+
+                <eventlog>
+                </eventlog>
+
+
                 """), new_file.read())