diff --git a/ennstatus/log.py b/ennstatus/log.py --- a/ennstatus/log.py +++ b/ennstatus/log.py @@ -1,6 +1,7 @@ import logging import logging.handlers +import os.path logging_debug_string = ('%(levelname)s:%(name)s:%(asctime)s:%(filename)s' ':%(lineno)d: %(message)s') @@ -16,6 +17,9 @@ def init_logging(app): stream_handler.setLevel(logging.DEBUG) stream_handler.setFormatter(logging_debug_formatter) + if not os.path.exists('log/ennstatus.log'): + open('log/ennstatus.log', mode='a').close() + rotating_file_handler = logging.handlers.RotatingFileHandler( 'log/ennstatus.log', maxBytes=1300000, @@ -24,7 +28,12 @@ def init_logging(app): rotating_file_handler.setLevel(logging.INFO) rotating_file_handler.setFormatter(logging_formatter) - if app.debug or ('ENABLE_DEBUG_LOG' in app.config and app.config['ENABLE_DEBUG_LOG']): + if app.debug or ('ENABLE_DEBUG_LOG' in app.config and + app.config['ENABLE_DEBUG_LOG']): + + if not os.path.exists('log/ennstatus_debug.log'): + open('log/ennstatus_debug.log', mode='a').close() + second_rotating_file_handler = logging.handlers.RotatingFileHandler( 'log/ennstatus_debug.log', maxBytes=1300000,