1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-22 02:17:26 +00:00

Merge pull request #73 from mkropat/syslog-logging

Tell Flask to log to syslog
This commit is contained in:
Joshua Tauberer 2014-06-21 21:22:27 -04:00
commit 064d75e261
2 changed files with 10 additions and 0 deletions

View File

@ -97,4 +97,8 @@ def do_updates():
if __name__ == '__main__': if __name__ == '__main__':
if "DEBUG" in os.environ: app.debug = True if "DEBUG" in os.environ: app.debug = True
if not app.debug:
app.logger.addHandler(utils.create_syslog_handler())
app.run(port=10222) app.run(port=10222)

View File

@ -95,3 +95,9 @@ def shell(method, cmd_args, env={}, capture_stderr=False, return_bytes=False):
ret = getattr(subprocess, method)(cmd_args, env=env, stderr=stderr) ret = getattr(subprocess, method)(cmd_args, env=env, stderr=stderr)
if not return_bytes and isinstance(ret, bytes): ret = ret.decode("utf8") if not return_bytes and isinstance(ret, bytes): ret = ret.decode("utf8")
return ret return ret
def create_syslog_handler():
import logging.handlers
handler = logging.handlers.SysLogHandler(address='/dev/log')
handler.setLevel(logging.WARNING)
return handler