objwatch.event_handls module¶
- class objwatch.event_handls.EventHandls(output_xml: str | None = None)[source]¶
Bases:
objectHandles various events for ObjWatch, including function execution and variable updates. Optionally saves the events in an XML format.
- __init__(output_xml: str | None = None) None[source]¶
Initialize the EventHandls with optional XML output configuration.
- Parameters:
output_xml (
Optional[str]) – Path to the XML file for writing structured logs.
- handle_run(lineno: int, func_info: dict, abc_wrapper: Any | None, call_depth: int, index_info: str) None[source]¶
Handle the ‘run’ event indicating the start of a function or method execution.
- handle_end(lineno: int, func_info: dict, abc_wrapper: Any | None, call_depth: int, index_info: str, result: Any) None[source]¶
Handle the ‘end’ event indicating the end of a function or method execution.
- handle_upd(lineno: int, class_name: str, key: str, old_value: Any, current_value: Any, call_depth: int, index_info: str, abc_wrapper: Any | None = None) None[source]¶
Handle the ‘upd’ event representing the creation or updating of a variable.
- Parameters:
lineno (
int) – The line number where the event is called.class_name (
str) – Name of the class containing the variable.key (
str) – Variable name.old_value (
Any) – Previous value of the variable.current_value (
Any) – New value of the variable.call_depth (
int) – Current depth of the call stack.index_info (
str) – Information about the index to track in a multi-process environment.abc_wrapper (
Optional[Any]) – Custom wrapper for additional processing.
- handle_apd(lineno: int, class_name: str, key: str, value_type: type, old_value_len: int | None, current_value_len: int | None, call_depth: int, index_info: str) None[source]¶
Handle the ‘apd’ event denoting the addition of elements to data structures.
- Parameters:
lineno (
int) – The line number where the event is called.class_name (
str) – Name of the class containing the data structure.key (
str) – Name of the data structure.value_type (
type) – Type of the elements being added.old_value_len (
int) – Previous length of the data structure.current_value_len (
int) – New length of the data structure.call_depth (
int) – Current depth of the call stack.index_info (
str) – Information about the index to track in a multi-process environment.
- handle_pop(lineno: int, class_name: str, key: str, value_type: type, old_value_len: int | None, current_value_len: int | None, call_depth: int, index_info: str) None[source]¶
Handle the ‘pop’ event marking the removal of elements from data structures.
- Parameters:
lineno (
int) – The line number where the event is called.class_name (
str) – Name of the class containing the data structure.key (
str) – Name of the data structure.value_type (
type) – Type of the elements being removed.old_value_len (
int) – Previous length of the data structure.current_value_len (
int) – New length of the data structure.call_depth (
int) – Current depth of the call stack.index_info (
str) – Information about the index to track in a multi-process environment.
- determine_change_type(old_value_len: int, current_value_len: int) EventType | None[source]¶
Determine the type of change based on the difference in lengths.
- static format_sequence(seq: Any, max_elements: int = 3, func: LambdaType | None = None) str[source]¶
Format a sequence to display a limited number of elements.