aws_lambda_powertools/logging/utils.py
def copy_config_to_registered_loggers(
    source_logger: Logger,
    log_level: Optional[str] = None,
    exclude: Optional[Set[str]] = None,
    include: Optional[Set[str]] = None,
) -> None:

    """Copies source Logger level and handler to all registered loggers for consistent formatting.

    Parameters
    ----------
    source_logger : Logger
        Powertools Logger to copy configuration from
    log_level : str, optional
        Logging level to set to registered loggers, by default uses source_logger logging level
    include : Optional[Set[str]], optional
        List of logger names to include, by default all registered loggers are included
    exclude : Optional[Set[str]], optional
        List of logger names to exclude, by default None
    """

    level = log_level or source_logger.level

    # Assumptions: Only take parent loggers not children (dot notation rule)
    # Steps:
    # 1. Default operation: Include all registered loggers
    # 2. Only include set? Only add Loggers in the list and ignore all else
    # 3. Include and exclude set? Add Logger if it’s in include and not in exclude
    # 4. Only exclude set? Ignore Logger in the excluding list

    # Exclude source logger by default
    if exclude:
        exclude.add(source_logger.name)
    else:
        exclude = set(source_logger.name)

    # Prepare loggers set
    if include:
        loggers = include.difference(exclude)
        filter_func = _include_registered_loggers_filter
    else:
        loggers = exclude
        filter_func = _exclude_registered_loggers_filter

    registered_loggers = _find_registered_loggers(source_logger, loggers, filter_func)
    for logger in registered_loggers:
        _configure_logger(source_logger, logger, level)
Copies source Logger level and handler to all registered loggers for consistent formatting.

    Parameters
    ----------
    source_logger : Logger
        Powertools Logger to copy configuration from
    log_level : str, optional
        Logging level to set to registered loggers, by default uses source_logger logging level
    include : Optional[Set[str]], optional
        List of logger names to include, by default all registered loggers are included
    exclude : Optional[Set[str]], optional
        List of logger names to exclude, by default None
    
Copies source Logger level and handler to all registered loggers for consistent formatting.
Parameters

source_logger : Logger
Powertools Logger to copy configuration from
log_level : str, optional
Logging level to set to registered loggers, by default uses source_logger logging level
include : Optional[Set[str]], optional
List of logger names to include, by default all registered loggers are included
exclude : Optional[Set[str]], optional
List of logger names to exclude, by default None
Copies source Logger level and handler to all registered loggers for consistent formatting . Parameters source_logger : Logger Powertools Logger to copy configuration from log_level : str optional Logging level to set to registered loggers by default uses source_logger logging level include : Optional [ Set [ str ]] optional List of logger names to include by default all registered loggers are included exclude : Optional [ Set [ str ]] optional List of logger names to exclude by default None
def copy_config_to_registered_loggers(
    source_logger: Logger,
    log_level: Optional[str] = None,
    exclude: Optional[Set[str]] = None,
    include: Optional[Set[str]] = None,
) -> None:
    level = log_level or source_logger.level
    if exclude:
        exclude.add(source_logger.name)
    else:
        exclude = set(source_logger.name)
    if include:
        loggers = include.difference(exclude)
        filter_func = _include_registered_loggers_filter
    else:
        loggers = exclude
        filter_func = _exclude_registered_loggers_filter
    registered_loggers = _find_registered_loggers(source_logger, loggers, filter_func)
    for logger in registered_loggers:
        _configure_logger(source_logger, logger, level)
def copy_config_to_registered_loggers ( source_logger : Logger , log_level : Optional [ str ] = None , exclude : Optional [ Set [ str ] ] = None , include : Optional [ Set [ str ] ] = None , ) -> None : level = log_level or source_logger . level if exclude : exclude . add ( source_logger . name ) else : exclude = set ( source_logger . name ) if include : loggers = include . difference ( exclude ) filter_func = _include_registered_loggers_filter else : loggers = exclude filter_func = _exclude_registered_loggers_filter registered_loggers = _find_registered_loggers ( source_logger , loggers , filter_func ) for logger in registered_loggers : _configure_logger ( source_logger , logger , level )
Copies source Logger level and handler to all registered loggers for consistent formatting.
Copies source Logger level and handler to all registered loggers for consistent formatting .
"""Copies source Logger level and handler to all registered loggers for consistent formatting.

    Parameters
    ----------
    source_logger : Logger
        Powertools Logger to copy configuration from
    log_level : str, optional
        Logging level to set to registered loggers, by default uses source_logger logging level
    include : Optional[Set[str]], optional
        List of logger names to include, by default all registered loggers are included
    exclude : Optional[Set[str]], optional
        List of logger names to exclude, by default None
    """ # Assumptions: Only take parent loggers not children (dot notation rule) # Steps: # 1. Default operation: Include all registered loggers # 2. Only include set? Only add Loggers in the list and ignore all else # 3. Include and exclude set? Add Logger if it’s in include and not in exclude # 4. Only exclude set? Ignore Logger in the excluding list # Exclude source logger by default # Prepare loggers set
source_logger
Logger
log_level
Optional[str]
exclude
Optional[Set[str]]
include
Optional[Set[str]]