Skip to content

pywry.log

Logging utilities for PyWry.


Logger Access

pywry.log.get_logger

get_logger() -> Logger

Get the pywry logger instance.

Returns:

Type Description
Logger

The pywry logger configured with a stream handler.

pywry.log.set_level

set_level(level: int | str) -> None

Set the logging level.

Parameters:

Name Type Description Default
level int or str

The logging level (e.g., logging.DEBUG, "DEBUG").

required

pywry.log.enable_debug

enable_debug() -> None

Enable debug mode for verbose IPC and operation logging.

This will show all debug messages including: - IPC command calls and responses - Event routing - Template application - Asset loading


Log Functions

pywry.log.debug

debug(msg: str) -> None

Log a debug message.

Parameters:

Name Type Description Default
msg str

The message to log.

required

pywry.log.info

info(msg: str) -> None

Log an info message.

Parameters:

Name Type Description Default
msg str

The message to log.

required

pywry.log.warn

warn(msg: str) -> None

Log a warning message. Never raises exceptions.

Parameters:

Name Type Description Default
msg str

The warning message to log.

required

pywry.log.error

error(msg: str) -> None

Log an error message. Never raises exceptions.

Parameters:

Name Type Description Default
msg str

The error message to log.

required

pywry.log.exception

exception(msg: str) -> None

Log an exception with full traceback.

Call this from within an except block to log the exception message along with the full stack trace.

Parameters:

Name Type Description Default
msg str

The error message to log alongside the traceback.

required

Helpers

pywry.log.log_callback_error

log_callback_error(event_type: str, label: str, exc: BaseException) -> None

Log a callback error with standardized format.

Parameters:

Name Type Description Default
event_type str

The event type that triggered the callback.

required
label str

The window label where the event occurred.

required
exc BaseException

The exception that was raised.

required

pywry.log.redact_sensitive_data

redact_sensitive_data(data: dict[str, Any] | list[Any] | str | None, max_depth: int = 5) -> dict[str, Any] | list[Any] | str | None

Redact sensitive values from data for safe logging.

Recursively traverses dicts/lists and replaces values for keys that match sensitive patterns with "[REDACTED]".

Parameters:

Name Type Description Default
data dict or list or str or None

The data to redact.

required
max_depth int

Maximum recursion depth to prevent infinite loops (default: 5).

5

Returns:

Type Description
dict or list or str or None

A copy of the data with sensitive values redacted.