utils
HeliosAOT Utility API
This module provides utility functions for various tasks.
Classes:
-
MarkdownRichHandler
–Custom logging handler for Rich library with Markdown support.
-
StepContext
–Context manager for logging steps in a process.
Functions:
-
get_version
–Get the version of the package
-
setup_logger
–Set up a logger with optional file output
-
suppress_os_stdio
–Context manager to suppress OS stdout and stderr
Copyright 2025 Ambiq. All Rights Reserved.
Classes
MarkdownRichHandler
Custom logging handler for Rich library with Markdown support.
StepContext
Functions
get_version
setup_logger
setup_logger(log_name: str, level: int | None = None, recursive: bool = True, file_path: str | Path | None = None) -> logging.Logger
Configure a logger with optional file output.
This function ensures that the logger is only initialized once per name. The logger can be configured to propagate messages to the root logger.
Included handlers are
- RichHandler: For console output with rich formatting.
- FileHandler: For file output (optional).
Parameters:
-
log_name
str
) –Name of the logger.
-
level
int
, default:None
) –Logging level (0: ERROR, 1: INFO, 2: DEBUG). Defaults to None.
-
recursive
bool
, default:True
) –If True, use the root logger name. Defaults to True.
-
file_path
str | Path
, default:None
) –Path to the log file. Defaults to None.
Returns:
-
Logger
–logging.Logger: Configured logger instance.