1 Console
utils.Console(**kwargs)Console wrapper that centralises formatting and convenience helpers.
1.1 Attributes
| Name | Description |
|---|---|
| verbosity | Global verbosity level shared across all Console instances. |
| verbose | Boolean view of verbosity (NORMAL or higher). |
| is_debug | Global debug flag shared across all Console instances. |
1.2 Methods
| Name | Description |
|---|---|
| with_prefix | Create a console instance with a prefixed context. |
| with_caller_prefix | Create a console with prefix inferred from the caller’s module and function. |
| from_callsite | Compatibility constructor mirroring the PRML VSLAM console API. |
| set_prefix | Set a custom prefix for all log messages. |
| unset_prefix | Unset the prefix for all log messages. |
| log | Emit an informational message when verbosity is enabled. |
| log_summary | Log a structured summary built from summarize. |
| warn | Emit a warning message and include a short caller stack. |
| error | Emit an error message and show the relevant caller stack. |
| plog | Pretty-print an object using the best available formatter. |
| dbg | Emit a debug message when debug mode is enabled. |
| dbg_summary | Debug-level structured summary. |
| set_verbosity | Set verbosity level (0=quiet, 1=normal, 2=verbose). |
| set_verbose | Backward-compatible alias for set_verbosity. |
| set_debug | Enable or disable debug logging while keeping verbose mode sensible. |
| set_timestamp_display | Toggle timestamps for subsequent log messages. |
| integrate_with_logger | Integrate all Console instances with PyTorch Lightning logger for WandB/TensorBoard logging. |
| update_global_step | Update the shared global step for all console instances. |
| set_sink | Register an external sink to receive plain-text log lines. |
1.2.1 with_prefix
utils.Console.with_prefix(*parts)Create a console instance with a prefixed context.
Enables builder-style chaining.
Usage:
console = Console.with_prefix(
self.__class__.__name__,
<name_of_the_current_method>
<further_parts>, # eg. stage, worker_idx...
)1.2.2 with_caller_prefix
utils.Console.with_caller_prefix(*extra_parts, stack_depth=1)Create a console with prefix inferred from the caller’s module and function.
1.2.3 from_callsite
utils.Console.from_callsite(*parts, stack_offset=0)Compatibility constructor mirroring the PRML VSLAM console API.
1.2.4 set_prefix
utils.Console.set_prefix(*parts)Set a custom prefix for all log messages.
Enables builder-style chaining.
1.2.5 unset_prefix
utils.Console.unset_prefix()Unset the prefix for all log messages.
1.2.6 log
utils.Console.log(message)Emit an informational message when verbosity is enabled.
1.2.7 log_summary
utils.Console.log_summary(label, value, *, include_stats=False)Log a structured summary built from summarize.
1.2.8 warn
utils.Console.warn(message)Emit a warning message and include a short caller stack.
1.2.9 error
utils.Console.error(message)Emit an error message and show the relevant caller stack.
1.2.10 plog
utils.Console.plog(obj, **kwargs)Pretty-print an object using the best available formatter.
1.2.11 dbg
utils.Console.dbg(message)Emit a debug message when debug mode is enabled.
1.2.12 dbg_summary
utils.Console.dbg_summary(label, value, *, include_stats=False)Debug-level structured summary.
1.2.13 set_verbosity
utils.Console.set_verbosity(level)Set verbosity level (0=quiet, 1=normal, 2=verbose).
1.2.14 set_verbose
utils.Console.set_verbose(verbose)Backward-compatible alias for set_verbosity.
1.2.15 set_debug
utils.Console.set_debug(is_debug)Enable or disable debug logging while keeping verbose mode sensible.
1.2.16 set_timestamp_display
utils.Console.set_timestamp_display(show_timestamps)Toggle timestamps for subsequent log messages.
1.2.17 integrate_with_logger
utils.Console.integrate_with_logger(logger, global_step=0)Integrate all Console instances with PyTorch Lightning logger for WandB/TensorBoard logging.
This is a class method that sets the shared logger state for all Console instances.
1.2.17.1 Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| logger | Logger | PyTorch Lightning logger instance (e.g., WandbLogger, TensorBoardLogger). | required |
| global_step | int | Current training step for metric logging. | 0 |
1.2.17.2 Returns
| Name | Type | Description |
|---|---|---|
| type[Console] | Console class for method chaining. |
1.2.17.3 Example
# In your LightningModule.__init__
Console.integrate_with_logger(self.logger)
# In training_step
def training_step(self, batch, batch_idx):
Console.update_global_step(self.global_step)
console = Console.with_prefix("training")
console.log("Processing batch") # → Terminal + WandB!1.2.18 update_global_step
utils.Console.update_global_step(global_step)Update the shared global step for all console instances.
1.2.19 set_sink
utils.Console.set_sink(sink)Register an external sink to receive plain-text log lines.