Bug fixes. Adjust logger

This commit is contained in:
Khanh Ngo
2019-12-10 17:08:43 +07:00
parent 9904505867
commit 67e6df6880
3 changed files with 22 additions and 9 deletions

View File

@ -1,7 +1,8 @@
import os
from werkzeug.middleware.proxy_fix import ProxyFix
import logging
from flask import Flask
from flask_seasurf import SeaSurf
from werkzeug.middleware.proxy_fix import ProxyFix
from .lib import utils
@ -11,6 +12,18 @@ def create_app(config=None):
from .assets import assets
app = Flask(__name__)
# Setting logger
logging.basicConfig(
format=
"[%(asctime)s] [%(filename)s:%(lineno)d] %(levelname)s - %(message)s")
# If we use Docker + Gunicorn, adjust the
# log handler
if "GUNICORN_LOGLEVEL" in os.environ:
gunicorn_logger = logging.getLogger("gunicorn.error")
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
# Proxy
app.wsgi_app = ProxyFix(app.wsgi_app)