Skip to main content

Lightweight Python logging tool for visual call tracing, tree-structured colored logs, and easy debugging with a simple decorator. Optimized for both standard and AI-generated codebases.

Project description

pyhunt_logo

pyhunt

pyhunt is a lightweight logging tool that visually represents logs for quick structural understanding and debugging.
Simply add a decorator to your functions, and all logs are automatically traced and displayed in your terminal.

PyPI version Python Versions

English | 한국어


https://github.com/user-attachments/assets/3d4389fe-4708-423a-812e-25f2e7200053

pyhunt_description

Features

  • Automatic Function/Method Call Tracing: Automatically records the flow of synchronous/asynchronous functions and classes with a single @trace decorator.
  • Rich Colors and Tree-Structured Logs: Enhances readability with color and indentation based on call depth.
  • Multiple Log Levels Supported: DEBUG, INFO, WARNING, ERROR, CRITICAL.
  • Set Log Level via CLI: Manage and store HUNT_LEVEL in a .env file.
  • Optimized for AI Workflows: Easily trace code generated by AI.
  • Detailed Exception Information: Includes call arguments, location, and stack trace on exceptions.

Installation

Install with pip

pip install pyhunt

Install with uv

uv add pyhunt

Quick Start

1. Set Up Environment Variable File

hunt

This command sets HUNT_LEVEL=DEBUG in your .env file.

2. Apply @trace to Functions or Classes

See more examples in the examples folder.

Basic Example

from pyhunt import trace

@trace
def test(value):
    return value

Asynchronous Function

@trace
async def test(value):
    return value

Class

@trace
class MyClass:
    def first_method(self, value):
        return value

    def second_method(self, value):
        return value

Using with AI

Rule Setup

Add the following rules to .cursorrules, .clinerules, or .roorules:

<logging-rules>

**Import:** Import the decorator with `from pyhunt import trace`.
**Tracing:** Use the `@trace` decorator to automatically log function calls and execution times.
**Avoid `print()`:** Do not use the `print()` function.
**Exception Handling:** Use `try`/`except Exception as e: raise e` blocks to maintain traceback.

</logging-rules>

Modifying Existing Codebase

Prompt: "Modify the code according to the logging rules."

Logger Usage

The logger interface is recommended for use only in important sections.
Most actions are traced via @trace, and excessive use may reduce readability.

from pyhunt import logger

logger.debug("This is a debug log.")
logger.info("This is an info log.")
logger.warning("This is a warning log.")
logger.error("This is an error log.")
logger.critical("This is a critical log.")

CLI Usage

hunt [options]

Supported Options

  • --debug : DEBUG level (most detailed)
  • --info : INFO level
  • --warning : WARNING level
  • --error : ERROR level
  • --critical : CRITICAL level

If no option is specified, the default is INFO.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhunt-1.1.1.tar.gz (141.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhunt-1.1.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pyhunt-1.1.1.tar.gz.

File metadata

  • Download URL: pyhunt-1.1.1.tar.gz
  • Upload date:
  • Size: 141.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for pyhunt-1.1.1.tar.gz
Algorithm Hash digest
SHA256 628465fd631b3856a74554cae4d69c022af2c85b60b666cd3f3a1c9adc983a52
MD5 e48853ffbd644145c59b141c65ead845
BLAKE2b-256 42ec1c86a8179b1af5c0571908aeb84382b1f5c11abc79f43cb02163682a853c

See more details on using hashes here.

File details

Details for the file pyhunt-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyhunt-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for pyhunt-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d996593e5c798b8c1a2dae8e6bbefdb91d050f3a3bfd01f7cffaf60540afa79b
MD5 eb5354dbb212b718b3d1fb1e0d3b828b
BLAKE2b-256 a11fe89ff59e1d4d1b11d674307dc23d398e1e9d2827af4c8efdcebcb04bf060

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page