Source code for haive.core.utils.debugkit.debugging
"""Enhanced Debugging UtilitiesA unified interface for all debugging capabilities including enhanced print debugging,interactive debugging, decorators, and inspection utilities.Examples: Enhanced debugging (icecream replacement): >>> from haive.core.utils.dev.debugging import debug >>> debug.ice("Hello", variable=42) Interactive debugging: >>> debug.pdb() # Enhanced pdb >>> debug.web(port=8080) # Web-based debugging >>> debug.visual() # Visual debugging with pudb Automatic exception debugging: >>> @debug.breakpoint_on_exception ... def risky_function(): ... # Will auto-debug on exceptions ... pass Call tracing: >>> @debug.trace_calls ... def tracked_function(): ... # Will show call trace ... pass Variable inspection: >>> debug.locals_inspect() # See local variables >>> debug.stack_trace() # See call stack"""fromhaive.core.utils.debugkit.debug.decoratorsimportdebug_decoratorsfromhaive.core.utils.debugkit.debug.enhancedimportenhanced_debuggerfromhaive.core.utils.debugkit.debug.inspectionimportdebug_inspectorfromhaive.core.utils.debugkit.debug.interactiveimportinteractive_debugger
[docs]classDebugUtilities:"""Unified interface for all debugging utilities."""def__init__(self):self.enhanced=enhanced_debuggerself.interactive=interactive_debuggerself.decorators=debug_decoratorsself.inspector=debug_inspector# Enhanced debugging methods
[docs]defice(self,*args,**kwargs):"""Enhanced print debugging with context (icecream replacement)."""returnself.enhanced.ice(*args,**kwargs)
[docs]defvisual(self,condition:bool=True)->None:"""Start visual debugging with pudb."""self.interactive.visual(condition)
# Decorators
[docs]defbreakpoint_on_exception(self,func):"""Decorator to automatically break into debugger on exceptions."""returnself.decorators.breakpoint_on_exception(func)
[docs]deftrace_calls(self,func):"""Decorator to trace function calls."""returnself.decorators.trace_calls(func)
[docs]deflocals_inspect(self)->dict:"""Inspect local variables in the calling frame."""returnself.inspector.locals_inspect()
[docs]defglobals_inspect(self)->dict:"""Inspect global variables in the calling frame."""returnself.inspector.globals_inspect()
# Management methods
[docs]defenable(self)->None:"""Enable all debugging utilities."""self.enhanced.enable()self.interactive.enable()self.decorators.enable()self.inspector.enable()
[docs]defdisable(self)->None:"""Disable all debugging utilities."""self.enhanced.disable()self.interactive.disable()self.decorators.disable()self.inspector.disable()