Я определил настраиваемый регистратор в mylogger.py , а каталог журнала определен как config.py как LOG_DIR = '/ var / log'. В mylogger.py регистратор выполняет некоторую работу init с LOG_DIR.
//mylogger.py
from flask import current_app
log_path = os.path.join(current_app.config['LOG_DIR'],"all.log")
handler = logging.FileHandler(filename = logPath)
....
//config.py
LOG_DIR = "/var/log"
Flask сообщает сообщение об ошибке:
This typically means that you attempted to use functionality that needed
to interface with the current application object in some way. To solve
this, set up an application context with modules.app_context(). See the
documentation for more information.
Как я могу использовать переменную в конфигурации .py в app_context? Спасибо.