import os import uuid from logging import INFO from owslogger import logger from dotenv import load_dotenv load_dotenv('.env') DATABASE_HOSTNAME = os.environ.get('DATABASE_HOSTNAME') DATABASE_USER_NAME = os.environ.get('DATABASE_USER_NAME') DATABASE_PASSWORD = os.environ.get('DATABASE_PASSWORD') DATABASE = os.environ.get('DATABASE') DEV_ENVIRONMENT = 'dev' ENVIRONMENT = os.environ.get('Environment', DEV_ENVIRONMENT) SCRIPT_NAME = 'convert-vendor-to-D3' APPLICATION_NAME = 'convert_vendor_to_D3' 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()})