Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
def log_request(self, handler):
log = logging.getLogger('demo')
log.addHandler('mongolog', collection='log', host=''))
if handler.get_status() < 400:
log_method =
elif handler.get_status() < 500:
log_method = log.warn
log_method = log.error
request_time = 1000.0 * handler.request.request_time()
log_message = '%d %s %.2fms' % (handler.get_status(), handler._request_summary(), request_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment