Changeset - 7a52b2cec0a3
[Not reviewed]
version_5
0 1 0
Dennis Fink - 10 years ago 2015-09-05 23:54:48
dennis.fink@c3l.lu
Create log files if they don't exists
1 file changed with 10 insertions and 1 deletions:
0 comments (0 inline, 0 general)
ennstatus/log.py
Show inline comments
 
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,
0 comments (0 inline, 0 general)