Logging (rpx_benchmark.logging_utils)¶
Thin wrappers over the stdlib logging module. Library modules
call get_logger(__name__) at module top; the CLI entrypoint calls
configure_logging(level) once to install a handler (rich when
available, plain otherwise).
logging_utils
¶
Structured logging for the RPX benchmark toolkit.
Library modules do not configure logging themselves. They only call
:func:get_logger at module top::
from rpx_benchmark.logging_utils import get_logger
log = get_logger(__name__)
def do_the_thing():
log.info("starting the thing")
log.debug("parameter x=%s", x)
The CLI entrypoint (and any application code driving the toolkit)
calls :func:configure_logging exactly once to attach a handler. If
rich is installed, a pretty :class:rich.logging.RichHandler is
used so library log lines render with colour, level icons, and path
markers alongside the benchmark progress UI. Otherwise we fall back to
the standard library handler.
The logger hierarchy mirrors the package structure
(rpx_benchmark, rpx_benchmark.hub, rpx_benchmark.runner...)
so power users can turn individual modules up or down with one call::
import logging
logging.getLogger("rpx_benchmark.hub").setLevel(logging.DEBUG)
Log level conventions
DEBUG— internal state useful for bug reports. Off by default.INFO— user-facing progress ("downloading split", "loaded model").WARNING— degradations the user should know about but that do not abort the run ("CUDA unavailable; falling back to CPU", "profiler unavailable; FLOPs not reported").ERROR— recoverable failures that abort one operation.CRITICAL— reserved for unrecoverable state.
get_logger(name: str) -> logging.Logger
¶
Return a module-scoped logger nested under the rpx_benchmark root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Usually |
required |
Returns:
| Type | Description |
|---|---|
Logger
|
A logger ready to use. Call |
Examples:
>>> from rpx_benchmark.logging_utils import get_logger
>>> log = get_logger("rpx_benchmark.hub")
>>> log.name
'rpx_benchmark.hub'
Source code in rpx_benchmark/logging_utils.py
configure_logging(level: str | int = 'INFO', *, force: bool = False, use_rich: Optional[bool] = None) -> logging.Logger
¶
Install a handler on the root rpx_benchmark logger.
Safe to call multiple times: subsequent calls are no-ops unless
force=True. The CLI calls this once at the start of main;
library users can call it from their own entrypoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str or int
|
Logging level name ( |
'INFO'
|
force
|
bool
|
If True, re-install the handler even if one is already present. Use with care — multiple handlers cause duplicate output. |
False
|
use_rich
|
bool
|
Force rich or plain handler selection. When omitted, auto-
detects: rich if the |
None
|
Returns:
| Type | Description |
|---|---|
Logger
|
The configured root logger, for chaining. |
Examples:
>>> from rpx_benchmark.logging_utils import configure_logging
>>> log = configure_logging("DEBUG")
>>> log.info("benchmark starting")
Source code in rpx_benchmark/logging_utils.py
set_level(level: str | int) -> None
¶
Shortcut for logging.getLogger('rpx_benchmark').setLevel(level).
Useful for quick toggles without re-running :func:configure_logging.