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