Skip to main content

No project description provided

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.0.tar.gz (111.8 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.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyhunt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 82268ff5610ff1506be3177077b566eaea8fe59100f51a0d6c1446338e4e34d4
MD5 edd4efd953dcb43e865963be56f71f6b
BLAKE2b-256 4944d38c3b31e68d349139371ee4688093a61bad8f240e9cade4f1e6f0568d4e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyhunt-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cb1930edf0363f3ba4d4e587527dde8792211b5d14e96b298cd138f61ce3458
MD5 34516ce1421fd1eb5b575a83b02c78ed
BLAKE2b-256 b791c79cbda20876801eee528b175dd5e086f41077d5979a1bb4fd93efc114c1

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