EzPrinter¶
Rich-based console output handler.
Overview¶
The EzPrinter class (alias: Printer) provides Rich-formatted console logging with pattern-based formatting. It wraps Rich Console to provide a simple and consistent API for console output.
Class Reference¶
EzPrinter
¶
EzPrinter(level: str = 'INFO', indent_step: int = 3, indent_symbol: str = '>', base_indent_symbol: str = '~')
Bases: LoggingHandler, IndentationManager
Console printer handler with advanced formatting and indentation support using Rich.
This handler provides console-based logging with: - Color-coded log levels using Rich - Indentation management - Robust character handling (Rich handles special characters automatically) - Context manager support - Pattern-based logging (SUCCESS, ERROR, WARN, TIP, etc.) - Access to RichWizard for advanced display features
Initialize the console printer handler.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
The desired logging level
TYPE:
|
indent_step
|
Number of spaces for each indentation level
TYPE:
|
indent_symbol
|
Symbol for indentation levels
TYPE:
|
base_indent_symbol
|
Symbol for the base indentation
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If the provided level is invalid |
Source code in src/ezpl/handlers/console.py
Attributes¶
level_manually_set
property
¶
Return whether level was set manually at runtime.
base_indent_symbol
property
¶
Return the configured base indentation symbol.
wizard
property
¶
wizard: RichWizard
Get the Rich Wizard instance for advanced display features.
| RETURNS | DESCRIPTION |
|---|---|
RichWizard
|
RichWizard instance for panels, tables, JSON, etc. |
Example
printer.wizard.success_panel("Success", "Operation completed") printer.wizard.status_table("Status", data) printer.wizard.dependency_table({"tool": "1.0.0"})
Functions¶
mark_level_as_configured
¶
set_level
¶
Set the logging level.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
The desired logging level
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If the provided level is invalid |
Source code in src/ezpl/handlers/console.py
log
¶
Log a message with the specified level.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
The log level
TYPE:
|
message
|
The message to log (any type, will be safely converted to string)
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If the level is invalid |
Source code in src/ezpl/handlers/console.py
info
¶
debug
¶
success
¶
warning
¶
warn
¶
error
¶
critical
¶
tip
¶
system
¶
install
¶
detect
¶
config
¶
deps
¶
print_pattern
¶
print_pattern(pattern: str | Pattern, message: Any, level: str = 'INFO') -> None
Display a message with pattern format: • PATTERN :: message
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Pattern name (string) or Pattern enum
TYPE:
|
message
|
Message to display
TYPE:
|
level
|
Log level for filtering (default: INFO)
TYPE:
|
Source code in src/ezpl/handlers/console.py
get_indent
¶
Get the current indentation string.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The current indentation string |
Source code in src/ezpl/handlers/console.py
add_indent
¶
del_indent
¶
reset_indent
¶
manage_indent
¶
Context manager for temporary indentation.
| YIELDS | DESCRIPTION |
|---|---|
None
|
None |
print_table
¶
Display a table using Rich (delegates to RichWizard).
| PARAMETER | DESCRIPTION |
|---|---|
data
|
List of dictionaries representing table rows
TYPE:
|
title
|
Optional table title
TYPE:
|
Source code in src/ezpl/handlers/console.py
print_panel
¶
Display a panel using Rich (delegates to RichWizard).
| PARAMETER | DESCRIPTION |
|---|---|
content
|
Panel content
TYPE:
|
title
|
Optional panel title
TYPE:
|
style
|
Panel style (Rich style string, used as border_style)
TYPE:
|
Source code in src/ezpl/handlers/console.py
print_progress
¶
Display a progress bar using Rich.
Note: This is a placeholder. For full progress functionality, users should use Rich's Progress context manager directly.
Source code in src/ezpl/handlers/console.py
print_json
¶
print_json(data: str | dict | list, title: str | None = None, indent: int | None = None, highlight: bool = True) -> None
Display JSON data in a formatted and syntax-highlighted way using Rich (delegates to RichWizard).
| PARAMETER | DESCRIPTION |
|---|---|
data
|
JSON data to display (dict, list, or JSON string)
TYPE:
|
title
|
Optional title for the JSON display
TYPE:
|
indent
|
Number of spaces for indentation (default: 2)
TYPE:
|
highlight
|
Whether to enable syntax highlighting (default: True)
TYPE:
|
Examples:
>>> printer.print_json({"name": "Alice", "age": 30})
>>> printer.print_json('{"key": "value"}', title="Config")
>>> printer.print_json([1, 2, 3], indent=4)