changeset 5989:4790615ddfb6

reimplement log_timing functionality
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 05 Jun 2013 00:37:14 +0200
parents 488a3cd30701
children aee4ff651134
files MoinMoin/wsgiapp.py docs/CHANGES
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wsgiapp.py	Tue Jun 04 22:48:59 2013 +0200
+++ b/MoinMoin/wsgiapp.py	Wed Jun 05 00:37:14 2013 +0200
@@ -252,8 +252,15 @@
             request = None
             request = self.Request(environ)
             context = init(request)
-            response = run(context)
-            context.clock.stop('total')
+            try:
+                response = run(context)
+            finally:
+                context.clock.stop('total')
+                if context.cfg.log_timing:
+                    dt = context.clock.timings['total']
+                    logging.info("timing: %s %s %s %3.3f %s" % (
+                        request.remote_addr, request.url, request.referrer,
+                        dt, "!" * int(dt) or "."))
         except HTTPException, e:
             response = e
         except error.ConfigurationError, e:
--- a/docs/CHANGES	Tue Jun 04 22:48:59 2013 +0200
+++ b/docs/CHANGES	Wed Jun 05 00:37:14 2013 +0200
@@ -38,6 +38,11 @@
     Output encoding is utf-8, columns are in this order:
     time, event, username, ip, wikiname, pagename, url, referrer, ua
     time: UNIX timestamp (float)
+  * reimplement cfg.log_timing - if True, emits INFO level log output like:
+    "timing: <REMOTE_ADDR> <URL> <REFERRER> <TIME> <SLOWNESS-INDICATOR>"
+    TIME is in seconds, the slowness indicator is "." for sub-second requests
+    or N times "!" for requests taking N seconds (so you easily can grep for
+    slow stuff).
 
   Fixes:
   * do not create empty pagedirs (with empty edit-log). To clean up all the