Revamp the logging a bit. Not quite done yet.

This commit is contained in:
Jake Moshenko 2014-05-01 19:44:28 -04:00
parent 3fb4fafb33
commit a5a61576ae
10 changed files with 91 additions and 52 deletions

View file

@ -1,23 +0,0 @@
import logging
import logstash_formatter
import gunicorn.glogging
from gunicorn import util
class LogstashLogger(gunicorn.glogging.Logger):
def _set_handler(self, log, output, fmt):
# remove previous gunicorn log handler
h = self._get_gunicorn_handler(log)
if h:
log.handlers.remove(h)
if output is not None:
if output == "-":
h = logging.StreamHandler()
else:
util.check_is_writeable(output)
h = logging.FileHandler(output)
h.setFormatter(logstash_formatter.LogstashFormatter())
h._gunicorn = True
log.addHandler(h)