log python errors to extra file

This commit is contained in:
b3yond 2018-04-14 15:22:05 +02:00
parent d280130b29
commit 27497e7129
2 changed files with 6 additions and 3 deletions

View file

@ -10,7 +10,7 @@ import time
if __name__ == '__main__':
logger = logging.getLogger()
fh = logging.StreamHandler()
fh = logging.FileHandler('/var/log/ticketfrei/error.log')
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)

View file

@ -160,7 +160,7 @@ def login_mastodon(user):
logger = logging.getLogger()
fh = logging.StreamHandler()
fh = logging.FileHandler('/var/log/ticketfrei/error.log')
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)
@ -169,4 +169,7 @@ bottle.install(SessionPlugin('/'))
if __name__ == '__main__':
# testing only
bottle.run(host='localhost', port=8080)
try:
bottle.run(host='localhost', port=8080)
except Exception:
logger.error('Unspecified Error.', exc_info=True)