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
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.
English | 한국어
https://github.com/user-attachments/assets/3d4389fe-4708-423a-812e-25f2e7200053
Features
- Automatic Function/Method Call Tracing: Automatically records the flow of synchronous/asynchronous functions and classes with a single
@tracedecorator. - 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_LEVELin a.envfile. - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyhunt-1.1.0.tar.gz.
File metadata
- Download URL: pyhunt-1.1.0.tar.gz
- Upload date:
- Size: 141.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
507fe91d32c39186bde5b7f6ac2c1b5bfc57228c0a0ff55c9b50573669d73d83
|
|
| MD5 |
aeae578ba2b0e82eab4b54b7479c29bf
|
|
| BLAKE2b-256 |
4883a0d202a8c0a4df96c8f0a68eba682d616b47a0b5c33e21d1f6c79eaef80c
|
File details
Details for the file pyhunt-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pyhunt-1.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bd0a7307b86e26921ae39a7fa2292d9d202bd0a6acf9834c5ba8f867da9e66c
|
|
| MD5 |
46f8b6dde43cabce3abfd82118a82d82
|
|
| BLAKE2b-256 |
be4611102e14f52f2fe702a3ea00431903a2c4b1e1dffd1b914386d0690bc570
|