Skip to content

logger

get_logger(name=__name__)

Initializes multi-GPU-friendly python logger.

Source code in quadra/utils/logger.py
 6
 7
 8
 9
10
11
12
13
14
15
def get_logger(name=__name__) -> logging.Logger:
    """Initializes multi-GPU-friendly python logger."""
    logger = logging.getLogger(name)

    # this ensures all logging levels get marked with the rank zero decorator
    # otherwise logs would get multiplied for each GPU process in multi-GPU setup
    for level in ("debug", "info", "warning", "error", "exception", "fatal", "critical"):
        setattr(logger, level, rank_zero_only(getattr(logger, level)))

    return logger