MicroLog, Python için yüksek performanslı asenkron logging kütüphanesidir.
Project description
MicroLog - Modern Python Logging Library
MicroLog is a thread-safe, asynchronous Python logging library designed for production environments. It provides distributed tracing support, high performance, and ease of use.
Features
- Asynchronous Logging - Non-blocking, queue-based background processing
- Distributed Tracing - Built-in support for
trace_id,span_id,parent_span_id - Multiple Formatters - JSON, Pretty (colored), and Compact formats
- File Rotation - Size-based rotation with gzip compression
- Email Notifications - SMTP handler with rate limiting
- Thread-Safe - Safe for concurrent operations
- High Performance - 47,000+ logs per second
- Production-Ready - Validated with 159 tests
Installation
From PyPI
pip install vi-microlog
From Source
# Clone the repository
git clone https://github.com/vidinsight-labs/MicroLog.git
cd MicroLog
# Install in development mode
pip install -e .
# Or use directly (add src directory to PYTHONPATH)
export PYTHONPATH=$(pwd)/src:$PYTHONPATH
Quick Start
from microlog import setup_logger, trace
import logging
# Create logger
logger = setup_logger("myapp", level=logging.INFO)
# Simple logging
logger.info("Application started")
# With trace context
with trace(trace_id="req-123"):
logger.info("Processing request")
Console Logger (Colored Output)
from microlog import setup_console_logger
logger = setup_console_logger("myapp", service_name="api-service", use_colors=True)
logger.info("Request processed", extra={"user_id": "123", "duration_ms": 45})
File Logger (JSON Format)
from microlog import setup_file_logger
logger = setup_file_logger(
name="myapp",
filename="app.log",
format_type="json",
max_bytes=10 * 1024 * 1024, # 10MB
backup_count=5
)
logger.info("Event occurred", extra={"event_type": "user_action"})
Distributed Tracing
from microlog import setup_logger, trace
logger = setup_logger("myapp")
# Automatic trace context
with trace(correlation_id="req-123") as ctx:
logger.info("Request received")
logger.info("Processing", extra={"trace_id": ctx.trace_id})
Decorator Support
from microlog import setup_logger, with_trace
logger = setup_logger("myapp")
@with_trace(correlation_id="order-456")
def process_order(order_id: str):
logger.info("Processing order", extra={"order_id": order_id})
Documentation
- Quickstart Guide - Get started in minutes
- Trace Context - Distributed tracing guide
- Formatters - JSON, Pretty, Compact formats
- Handlers - Async handlers and configuration
- File Management - Log rotation and compression
Test Status
- 159 tests - All tests passing (100%)
- Thread safety - Verified
- Memory stability - No leaks detected
- Performance - 47,000+ logs per second
- Production ready - Tested in API and microservice environments
Examples
The project includes 35+ examples organized in 8 categories:
- Quickstart - Minimal examples to get started
- Basic - Console and file logging
- Trace - Distributed tracing patterns
- Advanced - Custom handlers, thread safety
- Web - Flask, FastAPI, Django integrations
- Async - Async/await patterns
- Microservices - Service-to-service tracing
- Production - Production-ready configurations
Browse all examples: examples/README.md
Use Cases
Microservices
from microlog import setup_logger, trace
logger = setup_logger("api-gateway", service_name="gateway")
def handle_request(request):
with trace(correlation_id=request.headers.get("X-Request-ID")):
logger.info("Request received", extra={"path": request.path})
Production Logging
from microlog import setup_file_logger
logger = setup_file_logger(
name="production-app",
filename="/var/log/app.log",
format_type="json",
max_bytes=50 * 1024 * 1024,
backup_count=10,
compress=True
)
Requirements
- Python 3.7+
- No external dependencies (uses only Python standard library)
Contributing
Contributions are welcome! Please ensure all tests pass before opening an issue or submitting a PR.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Support
For questions, please open an issue or check the documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
- Repository: github.com/vidinsight-labs/MicroLog
- Issues: GitHub Issues
- Documentation: docs/
MicroLog - High-performance asynchronous logging library for Python
Project details
Release history Release notifications | RSS feed
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 vi_microlog-0.1.0.tar.gz.
File metadata
- Download URL: vi_microlog-0.1.0.tar.gz
- Upload date:
- Size: 45.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f89f9ba566d40e4fdb45a7dd331569a97144724e77e96b78bf95bdbf2408105
|
|
| MD5 |
b03b4a709f591539c11c6f01dc1b528f
|
|
| BLAKE2b-256 |
1efbb883d436db6959ffc34f11ff3a9d882c17bde8f25dca6dc6f4c088501fb7
|
File details
Details for the file vi_microlog-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vi_microlog-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ee58a1c9eef50201241fbb6062e7e4e00f9c6addb6d410ea3387b2cde0bdd3
|
|
| MD5 |
ba302dd4638a72371d2fb0451565d9c7
|
|
| BLAKE2b-256 |
63cb5f32158ee0baf288ad4c3280b92795f377778def412685810e83b888ee4d
|