fix logging when under gunicorn

fis returns in reports
This commit is contained in:
Aaron Kimbre 2022-02-16 13:33:12 -06:00
parent b829d666c9
commit 94411568ce
2 changed files with 13 additions and 1 deletions

View File

@ -47,6 +47,7 @@ def gen_item_report():
# Only one report per day
if report != None:
current_app.logger.info(f"Item Report Already Generated for {date}")
return
char_xmls = CharacterXML.query.join(
CharacterInfo,
@ -96,6 +97,7 @@ def gen_currency_report():
# Only one report per day
if report != None:
current_app.logger.info(f"Currency Report Already Generated for {date}")
return
characters = CharacterXML.query.join(
CharacterInfo,
@ -139,6 +141,7 @@ def gen_uscore_report():
# Only one report per day
if report != None:
current_app.logger.info(f"U-Score Report Already Generated for {date}")
return
characters = CharacterXML.query.join(
CharacterInfo,

11
wsgi.py
View File

@ -13,4 +13,13 @@ def make_shell_context():
if __name__ == '__main__':
with app.app_context():
app.run(host='0.0.0.0')
else:
import logging
from loggin.handlers import RotatingFileHandler
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
file_handler = RotatingFileHandler('nexus_dashboard.log', maxBytes=1024 * 1024 * 100, backupCount=20)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
app.logger.addHandler(file_handler)
app.logger.setLevel(gunicorn_logger.level)