Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup_logging(application):
with open(os.path.join(root, 'config/logging.yml'), 'rt') as f:
config = yaml.safe_load(f.read())
for logger in config['loggers']:
config['loggers'][logger]['level'] = application.config['LOG_LEVEL']
config['root']['level'] = application.config['LOG_LEVEL']
config['loggers']['prom2teams_app']['level'] = 'INFO'
environment = os.getenv('APP_ENVIRONMENT', 'None')
if environment == 'pro' or environment == 'pre':
config['handlers']['file']['filename'] = application.config['LOG_FILE_PATH']
for logger in config['loggers']:
config['loggers'][logger]['handlers'] = ['file']
config['root']['handlers'] = ['file']
else:
del config['handlers']['file']
def config_app(application):
try:
# Load the default configuration
application.config.from_object('prom2teams.config.settings')
# Load the configuration from the instance folder
instance = os.path.join(os.path.join(root, os.pardir), 'instance')
config = os.path.join(instance, 'config.py')
if os.path.isdir(instance) and os.path.exists(config):
application.config.from_pyfile(config)
# Load the file specified by the APP_CONFIG_FILE environment variable
# Variables defined here will override those in the default configuration
if 'APP_CONFIG_FILE' in os.environ:
application.config['APP_CONFIG_FILE'] = os.environ.get('APP_CONFIG_FILE')
config_provided = _config_provided(os.getenv('APP_CONFIG_FILE'))
_update_application_configuration(application, config_provided)
# Parse and load command line properties
# Variables defined here will override previous configuration
command_line_args = _config_command_line()
if command_line_args.configpath:
application.config['APP_CONFIG_FILE'] = command_line_args.configpath