Skip to content

logging #

Utilities to setup logging

Functions:

get_public_parent_module #

get_public_parent_module(name: str) -> str

Get the first public parent module of a module.

Parameters:

  • name (str) –

    The full name (e.g. 'mod_a.mod_b._mod_c') of the module.

Returns:

  • str

    The full name of the first public parent module (e.g. 'mod_a.mod_b').

Source code in femto/md/utils/logging.py
def get_public_parent_module(name: str) -> str:
    """Get the first public parent module of a module.

    Args:
        name: The full name (e.g. ``'mod_a.mod_b._mod_c'``) of the module.

    Returns:
        The full name of the first public parent module (e.g. ``'mod_a.mod_b'``).
    """

    parts = name.split(".")

    while parts and parts[-1].startswith("_"):
        parts.pop()

    return ".".join(parts)

get_parent_logger #

get_parent_logger(name: str) -> Logger

Returns the logger of the first public parent module of a module.

Parameters:

  • name (str) –

    The full name (e.g. 'mod_a.mod_b._mod_c') of the module.

Returns:

  • Logger

    The logger.

Source code in femto/md/utils/logging.py
def get_parent_logger(name: str) -> logging.Logger:
    """Returns the logger of the first public parent module of a module.

    Args:
        name: The full name (e.g. ``'mod_a.mod_b._mod_c'``) of the module.

    Returns:
        The logger.
    """

    return logging.getLogger(get_public_parent_module(name))