Skip to content

get_log_level

faststream.cli.utils.logs.get_log_level #

get_log_level(level)

Get the log level.

PARAMETER DESCRIPTION
level

The log level to get. Can be an integer, a LogLevels enum value, or a string.

TYPE: Union[LogLevels, str, int]

RETURNS DESCRIPTION
int

The log level as an integer.

Source code in faststream/cli/utils/logs.py
def get_log_level(level: Union[LogLevels, str, int]) -> int:
    """Get the log level.

    Args:
        level: The log level to get. Can be an integer, a LogLevels enum value, or a string.

    Returns:
        The log level as an integer.

    """
    if isinstance(level, int):
        return level

    if isinstance(level, LogLevels):
        return LOG_LEVELS[level.value]

    if isinstance(level, str):  # pragma: no branch
        return LOG_LEVELS[level.lower()]