parsl/monitoring/monitoring_base.py
def get_parsl_logger(
                  logger_name='parsl_monitor_logger',
                  is_logging_server=False,
                  monitoring_config=None,
                  **kwargs):
    """
    Parameters
    ----------
    logger_name : str, optional
        Name of the logger to use. Prevents adding repeat handlers or incorrect handlers
    is_logging_server : Bool, optional
        Used internally to determine which handler to return when using local db logging
    monitoring_config : MonitoringConfig, optional
        Pass in a logger class object to use for generating loggers.

    Returns
    -------
    logging.logger object

    Raises
    ------
    OptionalModuleMissing

    """

    logger = logging.getLogger(logger_name)

    if monitoring_config is None:
        logger.addHandler(NullHandler())
        return logger

    if monitoring_config.store is None:
        raise ValueError('No MonitoringStore defined')

    if is_logging_server:
        # add a handler that will take logs being received on the server and log them to the store
        handler = DatabaseHandler(monitoring_config.store.connection_string)
        # use the specific name generated by the server or the monitor wrapper
        logger = logging.getLogger(logger_name)
        logger.setLevel(logging.INFO)
        logger.addHandler(handler)
    else:
        # add a handler that will pass logs to the logging server
        handler = RemoteHandler(monitoring_config.store.logging_server_host, monitoring_config.store.logging_server_port)
        # use the specific name generated by the server or the monitor wrapper
        logger = logging.getLogger(logger_name)
        logger.setLevel(logging.INFO)
        logger.addHandler(handler)

    return logger
def get_parsl_logger(
                  logger_name='parsl_monitor_logger',
                  is_logging_server=False,
                  monitoring_config=None,
                  **kwargs):
    """
    Parameters
    ----------
    logger_name : str, optional
        Name of the logger to use. Prevents adding repeat handlers or incorrect handlers
    is_logging_server : Bool, optional
        Used internally to determine which handler to return when using local db logging
    monitoring_config : MonitoringConfig, optional
        Pass in a logger class object to use for generating loggers.

    Returns
    -------
    logging.logger object

    Raises
    ------
    OptionalModuleMissing

    """

    logger = logging.getLogger(logger_name)

    if monitoring_config is None:
        logger.addHandler(NullHandler())
        return logger

    if monitoring_config.store is None:
        raise ValueError('No MonitoringStore defined')

    if is_logging_server:
        # add a handler that will take logs being received on the server and log them to the store
        handler = DatabaseHandler(monitoring_config.store.connection_string)
        # use the specific name generated by the server or the monitor wrapper
        logger = logging.getLogger(logger_name)
        logger.setLevel(logging.INFO)
        logger.addHandler(handler)
    else:
        # add a handler that will pass logs to the logging server
        handler = RemoteHandler(monitoring_config.store.logging_server_host, monitoring_config.store.logging_server_port)
        # use the specific name generated by the server or the monitor wrapper
        logger = logging.getLogger(logger_name)
        logger.setLevel(logging.INFO)
        logger.addHandler(handler)

    return logger
Parameters
    ----------
    logger_name : str, optional
        Name of the logger to use. Prevents adding repeat handlers or incorrect handlers
    is_logging_server : Bool, optional
        Used internally to determine which handler to return when using local db logging
    monitoring_config : MonitoringConfig, optional
        Pass in a logger class object to use for generating loggers.

    Returns
    -------
    logging.logger object

    Raises
    ------
    OptionalModuleMissing