"""Application Logger. ====================== Creates application logger instance, that will send the logs to LOGGER_DSN. If config.LOGGER_DSN value is not set, the logs will be sent to stdout. """ import uuid from owslogger import logger from transcoding import config app_logger = logger.setup( config.ENVIRONMENT, config.LOGGER_NAME, config.LOGGER_LEVEL, 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() })