Skip to main content

A professional logging module using Azure Table Storage

Project description

Masterzdran Azure Table Storage Logging

mz-logging-azure-tablestorage

A professional Python logging module that uses Azure Table Storage for structured logging with support for trace IDs, metadata, and different log levels.

Features

  • Asynchronous logging using Azure Table Storage
  • Structured logging with comprehensive metadata
  • Trace ID support for request tracking
  • Automatic caller location tracking
  • Configurable log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • Dependency injection for flexible storage backends
  • Full type hinting support
  • Comprehensive test coverage

Installation

Install the package using pip:

pip install mz-logging-azure-tablestorage==1.0.0

For development installation:

pip install -e .[dev]

Quick Start

from mz_logging_azure_tablestorage import AzureLogger
from mz_logging_azure_tablestorage.storage import AzureTableStorage

# Initialize the storage
storage = AzureTableStorage(
    connection_string="your_azure_connection_string",
    table_name="logs"
)

# Create a logger instance
logger = AzureLogger(
    storage=storage,
    logger_name="my_service"
)

# Log messages with different levels
await logger.info("Operation completed", 
    metadata={"user_id": "123", "action": "login"})
await logger.error("Operation failed",
    trace_id="custom-trace",
    metadata={"error_code": "AUTH001"})

Configuration

The logger can be configured with the following parameters:

logger = AzureLogger(
    storage=storage,
    logger_name="my_service",
    default_trace_id="custom-default-trace"  # Optional
)

Log Levels

  • DEBUG: Detailed information for debugging
  • INFO: General information about program execution
  • WARNING: Indicates a potential problem
  • ERROR: A more serious problem
  • CRITICAL: A critical problem that may prevent program execution

Development

Setup Development Environment

  1. Clone the repository:
git clone git@github.com:masterzdran/mz-logging-azure-tablestorage.git
cd mz-logging-azure-tablestorage
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install development dependencies:
pip install -e .[dev]

Running Tests

Run the test suite:

pytest

Run with coverage:

pytest --cov=src --cov-report=html

Code Quality

Run code quality checks:

black .              # Code formatting
isort .             # Import sorting
pylint src/ tests/  # Linting
mypy src/           # Type checking

Building the Package

  1. Install build dependencies:
pip install build wheel
  1. Build the package:
python -m build

Publishing

  1. Install publishing dependencies:
pip install twine
  1. Upload to PyPI:
twine upload dist/*

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

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

mz_logging_azure_tablestorage-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

mz_logging_azure_tablestorage-1.0.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for mz_logging_azure_tablestorage-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9ca3e7527e53c5de708a57fe21920f27674842e14d48b817954593eb1aae30e1
MD5 e227ab31ab4e5b6bcc9950e32f4bc1f1
BLAKE2b-256 6933abdfeea51217f79a7e4a4b67fe92dec61e994e9157671fec58e9d2a32dce

See more details on using hashes here.

Provenance

The following attestation bundles were made for mz_logging_azure_tablestorage-1.0.0.tar.gz:

Publisher: main.yml on masterzdran/mz-logging-azure-tablestorage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for mz_logging_azure_tablestorage-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0eb515780bc4d0307ae45f057e186d53c3c58f3d3f23401fd88946426aea4d30
MD5 84551bc661ee15336c2a567ec91421c5
BLAKE2b-256 76f29882433c195a27d0b76936d60a66fd58572343dc17c757041542f29df975

See more details on using hashes here.

Provenance

The following attestation bundles were made for mz_logging_azure_tablestorage-1.0.0-py3-none-any.whl:

Publisher: main.yml on masterzdran/mz-logging-azure-tablestorage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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