Skip to content

Telemetry

provide.foundation.parsers.telemetry

TODO: Add module docstring.

Functions

parse_console_formatter

parse_console_formatter(value: str) -> ConsoleFormatterStr

Parse and validate console formatter string.

Parameters:

Name Type Description Default
value str

Formatter string (case-insensitive)

required

Returns:

Type Description
ConsoleFormatterStr

Valid formatter string in lowercase

Raises:

Type Description
ValueError

If the formatter is invalid

Source code in provide/foundation/parsers/telemetry.py
def parse_console_formatter(value: str) -> ConsoleFormatterStr:
    """Parse and validate console formatter string.

    Args:
        value: Formatter string (case-insensitive)

    Returns:
        Valid formatter string in lowercase

    Raises:
        ValueError: If the formatter is invalid

    """
    formatter = value.lower()
    if formatter not in _VALID_FORMATTER_TUPLE:
        raise ValueError(
            _format_invalid_value_error(
                "console_formatter",
                value,
                valid_options=list(_VALID_FORMATTER_TUPLE),
            ),
        )
    return cast("ConsoleFormatterStr", formatter)

parse_foundation_log_output

parse_foundation_log_output(value: str) -> str

Parse and validate foundation log output destination.

Parameters:

Name Type Description Default
value str

Output destination string

required

Returns:

Type Description
str

Valid output destination (stderr, stdout, main)

Raises:

Type Description
ValueError

If the value is invalid

Source code in provide/foundation/parsers/telemetry.py
def parse_foundation_log_output(value: str) -> str:
    """Parse and validate foundation log output destination.

    Args:
        value: Output destination string

    Returns:
        Valid output destination (stderr, stdout, main)

    Raises:
        ValueError: If the value is invalid

    """
    if not value:
        return "stderr"

    normalized = value.lower().strip()
    valid_options = ("stderr", "stdout", "main")

    if normalized in valid_options:
        return normalized
    raise ValueError(
        _format_invalid_value_error(
            "foundation_log_output",
            value,
            valid_options=list(valid_options),
        ),
    )

parse_log_level

parse_log_level(value: str) -> LogLevelStr

Parse and validate log level string.

Parameters:

Name Type Description Default
value str

Log level string (case-insensitive)

required

Returns:

Type Description
LogLevelStr

Valid log level string in uppercase

Raises:

Type Description
ValueError

If the log level is invalid

Source code in provide/foundation/parsers/telemetry.py
def parse_log_level(value: str) -> LogLevelStr:
    """Parse and validate log level string.

    Args:
        value: Log level string (case-insensitive)

    Returns:
        Valid log level string in uppercase

    Raises:
        ValueError: If the log level is invalid

    """
    level = value.upper()
    if level not in _VALID_LOG_LEVEL_TUPLE:
        raise ValueError(
            _format_invalid_value_error(
                "log_level",
                value,
                valid_options=list(_VALID_LOG_LEVEL_TUPLE),
            ),
        )
    return cast("LogLevelStr", level)