import os import uuid from logging import INFO from owslogger import logger from secrets_manager.python_ext import PythonSecretsManager DEV_ENVIRONMENT = 'dev' ENVIRONMENT = os.environ.get('Environment', DEV_ENVIRONMENT) SCRIPT_NAME = 'update-subaccount-id-mapping' APPLICATION_NAME = 'update_subaccount_id_mapping' secrets_manager_client = PythonSecretsManager( environment=ENVIRONMENT, service_name=SCRIPT_NAME) # art_relations mysql configs DATABASE_HOSTNAME = secrets_manager_client.get_cred('DATABASE_HOSTNAME') DATABASE_USER_NAME = secrets_manager_client.get_cred('DATABASE_USER_NAME') DATABASE_PASSWORD = secrets_manager_client.get_cred('DATABASE_PASSWORD') DATABASE = os.environ.get('DATABASE') LOGGING_LEVEL = INFO app_logger = logger.setup( ENVIRONMENT, SCRIPT_NAME, LOGGING_LEVEL, APPLICATION_NAME, '1.0.0' ) # logger def get_current_logger(correlation_id=None): """Get logger with a correlation_id attached. Args: correlation_id: correlation_id that will be sent along with log record Returns: logger.OwsLoggingAdapter: instance of OwsLoggingAdapter with correlation_id attached. """ return logger.OwsLoggingAdapter( app_logger, {'correlation_id': correlation_id or uuid.uuid4()})