Skip to content

pywry.log

Logging utilities for PyWry.


Logger Access

pywry.log.get_logger

get_logger() -> Logger

Get the pywry logger instance.

RETURNS DESCRIPTION
Logger

The pywry logger configured with a stream handler.

pywry.log.set_level

set_level(level: int | str) -> None

Set the logging level.

PARAMETER DESCRIPTION
level

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

TYPE: int or str

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.

PARAMETER DESCRIPTION
msg

The message to log.

TYPE: str

pywry.log.info

info(msg: str) -> None

Log an info message.

PARAMETER DESCRIPTION
msg

The message to log.

TYPE: str

pywry.log.warn

warn(msg: str) -> None

Log a warning message. Never raises exceptions.

PARAMETER DESCRIPTION
msg

The warning message to log.

TYPE: str

pywry.log.error

error(msg: str) -> None

Log an error message. Never raises exceptions.

PARAMETER DESCRIPTION
msg

The error message to log.

TYPE: str

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.

PARAMETER DESCRIPTION
msg

The error message to log alongside the traceback.

TYPE: str


Helpers

pywry.log.log_callback_error

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

Log a callback error with standardized format.

PARAMETER DESCRIPTION
event_type

The event type that triggered the callback.

TYPE: str

label

The window label where the event occurred.

TYPE: str

exc

The exception that was raised.

TYPE: BaseException

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]".

PARAMETER DESCRIPTION
data

The data to redact.

TYPE: dict or list or str or None

max_depth

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

TYPE: int DEFAULT: 5

RETURNS DESCRIPTION
dict or list or str or None

A copy of the data with sensitive values redacted.