You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.
The first possible mistake or maybe just something that most people might glance over is the fact that unless you setup within your config.py or any of the config files, a variable called LOG_FILE and set it to some value that does not come out to None or False then it will never enter the if statement. Maybe this was meant to say if app.config.get('LOG_FILENAME'): because that variable exists so this will run.
Although, one the loop is entered for the above code a TypeError exception is raised because the arguments passed to RotatingFileHandler are passed in the wrong order and what should be the backupCount argument (an integer) is actually passed the mode argument (a string) which you later run into comparing a string to an int which won't work. A simple fix would be to change the above to what I am posting below, or just change the order, though it may be more helpful to future users to explicitly pass them like below
Within the
logger_setup.py
file there is a mistake in this code here.if app.config.get('LOG_FILE'): file_handler = RotatingFileHandler(app.config['LOG_FILENAME'], app.config['LOG_MAXBYTES'], app.config['LOG_BACKUPS'], 'a', encoding='utf-8') file_handler.setLevel(logging.DEBUG) app.logger.addHandler(file_handler)
The first possible mistake or maybe just something that most people might glance over is the fact that unless you setup within your
config.py
or any of the config files, a variable calledLOG_FILE
and set it to some value that does not come out to None or False then it will never enter the if statement. Maybe this was meant to sayif app.config.get('LOG_FILENAME'):
because that variable exists so this will run.Although, one the loop is entered for the above code a TypeError exception is raised because the arguments passed to RotatingFileHandler are passed in the wrong order and what should be the backupCount argument (an integer) is actually passed the mode argument (a string) which you later run into comparing a string to an int which won't work. A simple fix would be to change the above to what I am posting below, or just change the order, though it may be more helpful to future users to explicitly pass them like below
if app.config.get('LOG_FILENAME'): file_handler = RotatingFileHandler(filename=app.config['LOG_FILENAME'], maxBytes=app.config['LOG_MAXBYTES'], backupCount=app.config['LOG_BACKUPS'], mode='a', encoding='utf-8') file_handler.setLevel(logging.DEBUG) app.logger.addHandler(file_handler)
The text was updated successfully, but these errors were encountered: