mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-04 00:17:06 +00:00
hook python's log to gunicorn's
This commit is contained in:
parent
bf63ca827e
commit
76e7528b34
@ -102,19 +102,21 @@ def add_python_logging(app):
|
|||||||
if app.debug:
|
if app.debug:
|
||||||
log_level = logging.DEBUG
|
log_level = logging.DEBUG
|
||||||
log_handler = logging.StreamHandler()
|
log_handler = logging.StreamHandler()
|
||||||
|
logging.basicConfig(level=log_level, handlers=[])
|
||||||
|
log_handler.setLevel(log_level)
|
||||||
|
log_handler.addFilter(AuthLogFilter(
|
||||||
|
app.debug,
|
||||||
|
get_session_username
|
||||||
|
))
|
||||||
|
log_handler.setFormatter(AuthLogFormatter())
|
||||||
|
log = logging.getLogger('')
|
||||||
|
log.addHandler(log_handler)
|
||||||
|
|
||||||
# log to syslog in production mode
|
# hook python log to gunicorn in production mode
|
||||||
else:
|
else:
|
||||||
import utils
|
gunicorn_logger = logging.getLogger('gunicorn.error')
|
||||||
log_level = logging.INFO
|
log = logging.getLogger('')
|
||||||
log_handler = utils.create_syslog_handler()
|
log.handlers = gunicorn_logger.handlers
|
||||||
|
log.setLevel(gunicorn_logger.level)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=log_level, handlers=[])
|
|
||||||
log_handler.setLevel(log_level)
|
|
||||||
log_handler.addFilter(AuthLogFilter(
|
|
||||||
app.debug,
|
|
||||||
get_session_username
|
|
||||||
))
|
|
||||||
log_handler.setFormatter(AuthLogFormatter())
|
|
||||||
log = logging.getLogger('')
|
|
||||||
log.addHandler(log_handler)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user