Skip to content

Commit

Permalink
Override tornado logging method to decrease pup log level�.
Browse files Browse the repository at this point in the history
Fix #414
  • Loading branch information
remh committed Mar 19, 2013
1 parent a3ee658 commit eab54dd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pup/pup.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,32 @@ def on_close(self):
"xsrf_cookies": True,
}



def tornado_logger(handler):
""" Override the tornado logging method.
If everything goes well, log level is DEBUG.
Otherwise it's WARNING or ERROR depending on the response code. """
if handler.get_status() < 400:
log_method = log.debug
elif handler.get_status() < 500:
log_method = log.warning
else:
log_method = log.error
request_time = 1000.0 * handler.request.request_time()
log_method("%d %s %.2fms", handler.get_status(),
handler._request_summary(), request_time)



application = tornado.web.Application([
(r"/", MainHandler),
(r"/(.*\..*$)", tornado.web.StaticFileHandler,
dict(path=settings['static_path'])),
(r"/pupsocket", PupSocket),
(r"/api/v1/series?", PostHandler),
(r"/intake", AgentPostHandler),
])
], log_function=tornado_logger)

def run_pup(config):
""" Run the pup server. """
Expand Down

0 comments on commit eab54dd

Please sign in to comment.