mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
logs: Don't display database time when there were no queries.
(imported from commit 71297c920b63578ebc2770954345bfb9d4d8937f)
This commit is contained in:
@@ -36,7 +36,11 @@ class LogRequests(object):
|
|||||||
optional_orig_delta = " (lp: %s)" % (format_timedelta(orig_time_delta),)
|
optional_orig_delta = " (lp: %s)" % (format_timedelta(orig_time_delta),)
|
||||||
|
|
||||||
# Get the amount of time spent doing database queries
|
# Get the amount of time spent doing database queries
|
||||||
|
db_time_output = ""
|
||||||
|
if len(connection.queries) > 0:
|
||||||
query_time = sum(float(query.get('time', 0)) for query in connection.queries)
|
query_time = sum(float(query.get('time', 0)) for query in connection.queries)
|
||||||
|
db_time_output = " (db: %s/%sq)" % (format_timedelta(query_time),
|
||||||
|
len(connection.queries))
|
||||||
|
|
||||||
# Get the requestor's email address and client, if available.
|
# Get the requestor's email address and client, if available.
|
||||||
try:
|
try:
|
||||||
@@ -48,11 +52,10 @@ class LogRequests(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
client = "?"
|
client = "?"
|
||||||
|
|
||||||
logger.info('%-15s %-7s %3d %5s%s (db: %s/%sq) %s (%s via %s)' %
|
logger.info('%-15s %-7s %3d %5s%s%s %s (%s via %s)' %
|
||||||
(remote_ip, request.method, response.status_code,
|
(remote_ip, request.method, response.status_code,
|
||||||
format_timedelta(time_delta), optional_orig_delta,
|
format_timedelta(time_delta), optional_orig_delta,
|
||||||
format_timedelta(query_time), len(connection.queries),
|
db_time_output, request.get_full_path(), email, client))
|
||||||
request.get_full_path(), email, client))
|
|
||||||
|
|
||||||
# Log some additional data whenever we return certain 40x errors
|
# Log some additional data whenever we return certain 40x errors
|
||||||
if 400 <= response.status_code < 500 and response.status_code not in [401, 404, 405]:
|
if 400 <= response.status_code < 500 and response.status_code not in [401, 404, 405]:
|
||||||
|
|||||||
Reference in New Issue
Block a user