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 | 한국어

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 Methods

@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` blocks and re-raise exceptions with `raise` to maintain traceback.

</logging-rules>

Modifying Existing Codebase

Command: "Modify the codebase according to the logging rules."

Logger Usage

The logger interface is recommended for use only in critical 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.0.1.tar.gz (112.6 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.0.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyhunt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f6ab11f0757ef8946f6bf32d0b76c9b0b8a841a506ee65e130994b8af8f2a970
MD5 6975977f4fd8559f2d6754749f442358
BLAKE2b-256 d4a14811ec2e82c1d5c15e91f795086cc13ce9782b9b31531d4d6ff3bd52c7da

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyhunt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a67d5b2850379f0d784f3a1ccb1aea56d016abff09c8e883485cd730a6b7a41
MD5 c93f7174ed9e3595973e0a2900893db2
BLAKE2b-256 f28ae67e2a5382aea7379e129e6452bffbf4d68eda0de73021effe88bdd9dffa

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