Hunter

3.9.0 · active · verified Sat Apr 11

Hunter is a flexible code tracing toolkit for debugging, logging, and inspection, not for code coverage. It offers a simple Python API, a convenient terminal API, and a CLI tool. The library is currently at version 3.9.0 and is actively maintained with a regular release cadence.

Warnings

Install

Imports

Quickstart

This example demonstrates how to activate Hunter to trace calls within the 'os.path' module using the `CallPrinter` action, both explicitly and via a context manager for localized tracing. Remember to call `hunter.stop()` when tracing is no longer needed to avoid overhead.

import hunter
import os

def my_function():
    return os.path.join('a', 'b')

# Activate tracing for the 'os.path' module with CallPrinter action
hunter.trace(module='os.path', action=hunter.CallPrinter)

print(f"Result: {my_function()}")

# Deactivate tracing
hunter.stop()

# You can also use it with a context manager (preferred for local scope)
with hunter.trace(module='os.path', action=hunter.CallPrinter):
    print(f"Result from context: {os.path.join('x', 'y')}")

view raw JSON →