A lightweight Python decorator for measuring execution time and system resource usage.
Project description
🚀 logg_it - Python Logging Utility
logg_it is a versatile logging utility designed to simplify logging for Python applications, featuring powerful stdout capture, automated exception logging, and customizable output.
✨ Features
- Automatic Exception Logging: Automatically logs exceptions and highlights the problematic line.
- Stdout Capture: Captures outputs from
print()statements. - Multiple Outputs: Supports logging to console, file, or both.
- Flexible Logging Levels: Customizable verbosity (DEBUG, INFO, WARNING, ERROR).
- Custom Formats: Define custom log message structures.
- Error-Focused Mode: Optionally logs only errors.
- Function Tagging: Tags logs with the originating function name.
- Highlight Errors: Clearly identifies error locations.
📦 Installation
pip install easy-logger
⚡ Quick Examples
Decorator Example
from easy-logger import logg_it
@logg_it(log_file='logs/example.log', level=logging.DEBUG)
def sample_function():
print("Hello from function!")
raise ValueError("Example Exception")
Context Manager Example
with logg_it(log_file='logs/example.log', level=logging.INFO):
print("Hello from context!")
1 / 0 # Automatically logs exception
⚙️ Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
log_file |
str |
None |
Path for file logging. Optional. |
level |
int |
logging.INFO |
Logging level. |
log_to_console |
bool |
True |
Output logs to console. |
log_format |
str |
Default format | Customizable log format. |
log_errors_only |
bool |
False |
If true, logs only errors. |
🛠️ Development
Clone repository for local development:
git clone https://github.com/brianvess/logg_it.git
cd your-repo
pip install -e .
📄 Example Log Output
2024-03-10 10:15:00 - INFO - Captured Output: "Hello from function!"
2024-03-10 10:15:01 - ERROR - Exception in [sample_function]: ValueError: Example Exception
🔴 🔥 **sample.py, line 4**
file.name 🌟 Credits
Developed by Brian Vess. If you find this useful, please ⭐ star this repository and contribute! 🚀
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 easy_py_logger-1.0.0.tar.gz.
File metadata
- Download URL: easy_py_logger-1.0.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2b39afee23c16dc3c4c0f24055099304e6174f50f3acfaefdb308d95cf88ad4
|
|
| MD5 |
a5d82de77f8a55946bb3bbd62ab815f5
|
|
| BLAKE2b-256 |
532707acaf13c7818489c303cd1e34e8620009cde046c3c710ae968aa9d6959d
|
File details
Details for the file easy_py_logger-1.0.0-py3-none-any.whl.
File metadata
- Download URL: easy_py_logger-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84a980babb2d73fa8bbe9f44e2cc663b9f5b0e97e9e30bcb93089ae034ef5e1b
|
|
| MD5 |
4ce632e841cf1e99da4749a5aefa6723
|
|
| BLAKE2b-256 |
62fa56a80676157c93c87c915d12c40f4ad424a8e7dd7fa1b0701c8a4789fdc0
|