Skip to main content

MicroLog, Python için yüksek performanslı asenkron logging kütüphanesidir.

Project description

LinkedIn Banner Design

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.

Python 3.7+ License: MIT

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

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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


MicroLog - High-performance asynchronous logging library for Python

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

vi_microlog-0.1.0.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vi_microlog-0.1.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

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

Hashes for vi_microlog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f89f9ba566d40e4fdb45a7dd331569a97144724e77e96b78bf95bdbf2408105
MD5 b03b4a709f591539c11c6f01dc1b528f
BLAKE2b-256 1efbb883d436db6959ffc34f11ff3a9d882c17bde8f25dca6dc6f4c088501fb7

See more details on using hashes here.

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

Hashes for vi_microlog-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10ee58a1c9eef50201241fbb6062e7e4e00f9c6addb6d410ea3387b2cde0bdd3
MD5 ba302dd4638a72371d2fb0451565d9c7
BLAKE2b-256 63cb5f32158ee0baf288ad4c3280b92795f377778def412685810e83b888ee4d

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