log python errors to extra file

master
b3yond 2018-04-14 15:22:05 +02:00
parent 9b5440ee7e
commit 3a9770d548
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)