"""Logger util.""" from logging import INFO import uuid from lambdacommon import util from owslogger import logger def get_current_logger( environment, lambda_name, logging_level=INFO, correlation_id=None): """Get logger with a correlation_id attached. Args: environment: environment on which this is run lambda_name: name of the calling lambda, usually from config.py logging_level: desired logging_level correlation_id: correlation_id that will be sent along with log record Returns: logger.OwsLoggingAdapter: instance of OwsLoggingAdapter with correlation_id attached. """ app_logger = util.setup_ows_logger( environment=environment, logger_name=lambda_name, logger_level=logging_level, service_name=lambda_name, service_version='1.0.0' ) return logger.OwsLoggingAdapter( app_logger, {'correlation_id': correlation_id or uuid.uuid4()})