"""Application Logger. ====================== Creates application logger instance. If config.LOGGER_DSN value is not set, the logs will be sent to stdout. """ import logging import uuid from owslogger import logger from auth0_sync_env import config app_logger = logger.setup( config.LOGGER_DSN, config.ENVIRONMENT, 'ows1', logging.INFO, config.APP_NAME, config.APP_VERSION) 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() })