# HG changeset patch # User Sylvain Thénault # Date 1479489381 -3600 # Node ID a997e5451737063c4a464455262848a3ca5508d0 # Parent 5f71460236a447a401976cefcead8f549ff3dcc9 [web] Enhance query log file * Add an overall page generation time * Don't log URL without any query (e.g. static files) diff -r 5f71460236a4 -r a997e5451737 cubicweb/web/application.py --- a/cubicweb/web/application.py Thu Nov 24 14:26:12 2016 +0100 +++ b/cubicweb/web/application.py Fri Nov 18 18:16:21 2016 +0100 @@ -252,15 +252,18 @@ return set_cnx req.set_cnx = wrap_set_cnx(req.set_cnx) + tstart, cstart = time(), clock() try: return self.main_handle_request(req) finally: cnx = req.cnx - if cnx: + if cnx and cnx.executed_queries: with self._logfile_lock: + tend, cend = time(), clock() try: result = ['\n' + '*' * 80] - result.append(req.url()) + result.append('%s -- (%.3f sec, %.3f CPU sec)' % ( + req.url(), tend - tstart, cend - cstart)) result += ['%s %s -- (%.3f sec, %.3f CPU sec)' % q for q in cnx.executed_queries] cnx.executed_queries = []