""" Application Logger. Creates application logger instance, that will send the logs to Loggly. It is used only for the daemon, as microservice has flask_logger integrated. """ import uuid from owslogger import logger from availability import config app_logger = logger.setup( environment=config.ENVIRONMENT, logger_name=config.DAEMON_NAME, logger_level=config.LOGGER_LEVEL, service_name=config.SERVICE_NAME, service_version=config.DAEMON_VERSION ) def get_current_logger(correlation_id=None): """Get logger with a correlation_id attached. Args: correlation_id (str): correlation_id that will be sent along with a log record. Returns: logger.OwsLoggingAdapter: instance of OwsLoggingAdapter with correlation_id attached. """ return logger.OwsLoggingAdapter( app_logger, {'correlation_id': correlation_id or uuid.uuid4()})