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.0.2.tar.gz (142.2 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.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyhunt-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b6b08ed904ed79d9ec54f45b642419eaf204032b5b7231e3aa046666cb75c8df
MD5 17c82e10cef5e2bc1a56cf723f346ed8
BLAKE2b-256 ffebbbae2f3603ac33cccf16c4a20c006b83ee8089274ed4ef5d50e394a520f4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyhunt-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f425d08e4b17e1260da0abeb0b9877fc902db9417a62c9a9fe29d07b49d442d6
MD5 413b635998e11054ad004a36c8400c83
BLAKE2b-256 2ef5473b0e9771919f207efd9bd487a9a091b33970f34ae8e0adf28371c1793b

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