objwatch package

Module contents

ObjWatch Package

A Python library to trace and monitor object attributes and method calls.

Exports:

ObjWatch: The main class for setting up and managing tracing. watch: A convenience function to start tracing with default settings.

class objwatch.ObjWatch(targets: List[str | ModuleType], exclude_targets: List[str | ModuleType] | None = None, framework: str | None = None, indexes: List[int] | None = None, output: str | None = None, output_xml: str | None = None, level: int = 10, simple: bool = False, wrapper: ABCWrapper | None = None, with_locals: bool = False, with_globals: bool = False)[source]

Bases: object

Tracing and logging of specified Python modules to aid in debugging and monitoring.

__init__(targets: List[str | ModuleType], exclude_targets: List[str | ModuleType] | None = None, framework: str | None = None, indexes: List[int] | None = None, output: str | None = None, output_xml: str | None = None, level: int = 10, simple: bool = False, wrapper: ABCWrapper | None = None, with_locals: bool = False, with_globals: bool = False) None[source]

Initialize the ObjWatch instance with configuration parameters.

Parameters:
  • targets (List[Union[str, ModuleType]]) – Files or modules to monitor.

  • exclude_targets (Optional[List[Union[str, ModuleType]]]) – Files or modules to exclude from monitoring.

  • framework (Optional[str]) – The multi-process framework module to use.

  • indexes (Optional[List[int]]) – The indexes to track in a multi-process environment.

  • output (Optional[str]) – Path to a file for writing logs.

  • output_xml (Optional[str]) – Path to the XML file for writing structured logs.

  • level (int) – Logging level (e.g., logging.DEBUG, logging.INFO).

  • simple (bool) – Enable simple logging mode with the format “DEBUG: {msg}”.

  • wrapper (Optional[ABCWrapper]) – Custom wrapper to extend tracing and logging functionality.

  • with_locals (bool) – Enable tracing and logging of local variables within functions.

  • with_globals (bool) – Enable tracing and logging of global variables across function calls.

start() None[source]

Start the ObjWatch tracing process.

stop() None[source]

Stop the ObjWatch tracing process.

__enter__() ObjWatch[source]

Enter the runtime context related to this object.

Returns:

The ObjWatch instance itself.

Return type:

ObjWatch

__exit__(exc_type: type | None, exc_val: BaseException | None, exc_tb: Any | None) None[source]

Exit the runtime context and stop tracing.

Parameters:
  • exc_type (Optional[type]) – The exception type.

  • exc_val (Optional[BaseException]) – The exception value.

  • exc_tb (Optional[Any]) – The traceback object.

objwatch.watch(targets: List[str | ModuleType], exclude_targets: List[str | ModuleType] | None = None, framework: str | None = None, indexes: List[int] | None = None, output: str | None = None, output_xml: str | None = None, level: int = 10, simple: bool = False, wrapper: ABCWrapper | None = None, with_locals: bool = False, with_globals: bool = False) ObjWatch[source]

Initialize and start an ObjWatch instance.

Parameters:
  • targets (List[Union[str, ModuleType]]) – Files or modules to monitor.

  • exclude_targets (Optional[List[Union[str, ModuleType]]]) – Files or modules to exclude from monitoring.

  • framework (Optional[str]) – The multi-process framework module to use.

  • indexes (Optional[List[int]]) – The indexes to track in a multi-process environment.

  • output (Optional[str]) – Path to a file for writing logs.

  • output_xml (Optional[str]) – Path to the XML file for writing structured logs.

  • level (int) – Logging level (e.g., logging.DEBUG, logging.INFO).

  • simple (bool) – Enable simple logging mode with the format “DEBUG: {msg}”.

  • wrapper (Optional[ABCWrapper]) – Custom wrapper to extend tracing and logging functionality.

  • with_locals (bool) – Enable tracing and logging of local variables within functions.

  • with_globals (bool) – Enable tracing and logging of global variables across function calls.

Returns:

The initialized and started ObjWatch instance.

Return type:

ObjWatch

Submodules

Subpackages