# HG changeset patch # User Dennis Fink # Date 2015-09-05 23:54:48 # Node ID 7a52b2cec0a3e856e7becbe9bf92731c624b4391 # Parent bb7fac8c2dc1d1e3a1fef4e1fb318de28e8ca9c3 Create log files if they don't exists 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,