PySnooper is a diagnostic library for Python that tracks variable values and execution flow to provide a detailed history of program state. By applying decorators to functions, generators, or classes, it logs line-by-line execution and state changes without requiring manual print statements.
The tool distinguishes itself through its ability to monitor nested function calls and concurrent operations in multi-threaded applications. It captures execution context by accessing the current stack frame, allowing for the inspection of local variables and the evaluation of arbitrary expressions during runtime.
The library supports extensive customization of diagnostic output, including the ability to redirect logs to files, streams, or custom destinations. It provides granular control over tracing, enabling users to filter variable contents, adjust output formatting, and manage monitoring scope through environment variables or direct code annotations.