Skip to content

Edk2 logging

edk2_logging

Handles basic logging config for invocables.

edk2_logging will automatically filter logs for PATs / Secrets when it is detected that the invocable is running on a CI system. It does this via searching for "CI" or "TF_BUILD" in the os's environment variables. If either of these exists and and are set to TRUE, filtering will occur.

Splits logs into a master log and per package log.

Edk2LogFilter

Subclass of logging.Filter.

__init__

__init__() -> None

Inits a filter.

setVerbose

setVerbose(isVerbose: bool = True) -> None

Sets the filter verbosity.

addSection

addSection(section: str) -> None

Adds a section to the filter.

filter

filter(record: logging.LogRecord) -> bool

Adds a filter for a record if it doesn't already exist.

clean_build_logs

clean_build_logs(
    ws: str, sub_directory: Optional[str] = None
) -> None

Removes all build logs.

get_section_level

get_section_level() -> int

Returns SECTION.

get_subsection_level

get_subsection_level() -> int

Returns SUB_SECTION.

get_progress_level

get_progress_level() -> int

Returns PROGRESS.

get_edk2_filter

get_edk2_filter(verbose: bool = False) -> logging.Filter

Returns an edk2 filter.

log_progress

log_progress(message: str) -> None

Creates a logging message at the progress section level.

setup_section_level

setup_section_level() -> None

Sets up different sections to log to.

setup_txt_logger

setup_txt_logger(
    directory: str,
    filename: str = "log",
    logging_level: int = logging.INFO,
    formatter: Optional[logging.Formatter] = None,
    logging_namespace: Optional[str] = "",
    isVerbose: bool = False,
) -> tuple

Configures a text logger.

setup_console_logging

setup_console_logging(
    logging_level: int = logging.INFO,
    formatter: Optional[logging.Formatter] = None,
    logging_namespace: Optional[str] = "",
    isVerbose: bool = False,
    use_azure_colors: bool = False,
    use_color: bool = True,
) -> logging.Handler

Configures a console logger.

Filtering of secrets will automatically occur if "CI" or "TF_BUILD" is set to TRUE in the os's environment.

stop_logging

stop_logging(
    loghandle: Union[
        list[logging.Handler], logging.Handler
    ],
    logging_namespace: Optional[str] = "",
) -> None

Stops logging on a log handle.

create_output_stream

create_output_stream(
    level: int = logging.INFO,
    logging_namespace: Optional[str] = "",
) -> logging.Handler

Creates an output stream to log to.

remove_output_stream

remove_output_stream(
    handler: logging.Handler,
    logging_namespace: Optional[str] = "",
) -> None

Removes an output stream to log to.

scan_compiler_output

scan_compiler_output(output_stream: TextIO) -> list[tuple]

Scans the compiler for errors and warnings.

Returns:

Type Description
list[tuple[Type, str]]

list of tuples containing the type of issue (Error, warning) and the description.