Skip to main content

Developer-focused logging library for Python with OpenSearch integration.

Project description

devlogs

A developer-focused logging library for Python with OpenSearch integration.

Quickstart

  1. Install devlogs:

    pip install devlogs
    
  2. Start OpenSearch:

    docker-compose up -d opensearch
    

    Or point DEVLOGS_OPENSEARCH_* at an existing cluster.

  3. Initialize indices/templates:

    devlogs init
    
  4. Use in Python code:

    import logging
    from devlogs.handler import OpenSearchHandler
    from devlogs.context import operation
    
    handler = OpenSearchHandler(level=logging.DEBUG)
    logging.getLogger().addHandler(handler)
    logging.getLogger().setLevel(logging.DEBUG)
    
    with operation(area="web"):
    	 logging.info("Hello from devlogs!", extra={"features": {"user": "alice", "plan": "pro"}})
    
  5. Tail logs from CLI:

    devlogs tail --area web --follow
    
  6. Search logs from CLI:

    devlogs search --q "error" --area web
    
  7. Run the web UI:

    uvicorn devlogs.web.server:app --port 8088
    # Then open http://localhost:8088/ui/
    

Using devlogs in another project

  1. Install devlogs:

    pip install devlogs
    
  2. Add the diagnostics handler:

    import logging
    from devlogs.handler import DiagnosticsHandler
    from devlogs.opensearch.client import get_opensearch_client
    from devlogs.context import operation
    
    client = get_opensearch_client()
    handler = DiagnosticsHandler(opensearch_client=client, index_name="devlogs-0001")
    logging.getLogger().addHandler(handler)
    logging.getLogger().setLevel(logging.DEBUG)
    
    with operation(area="web"):
    	 logging.info("request started")
    

Features

  • Standard logging.Handler for OpenSearch
  • Context manager for operation_id/area
  • Structured feature pairs on log entries (extra={"features": {...}})
  • CLI and Linux shell wrapper
  • Minimal embeddable web UI
  • Robust tests (pytest)

Configuration

Environment variables:

  • OpenSearch connection: DEVLOGS_OPENSEARCH_HOST, DEVLOGS_OPENSEARCH_PORT, DEVLOGS_OPENSEARCH_USER, DEVLOGS_OPENSEARCH_PASS
  • Index: DEVLOGS_INDEX
  • Retention (supports duration strings like 24h, 7d): DEVLOGS_RETENTION_DEBUG, DEVLOGS_RETENTION_INFO, DEVLOGS_RETENTION_WARNING

See .env.example for a complete configuration template.

Project Structure

  • src/devlogs/ - Python library, CLI, MCP server, and web UI
  • devlogs - Shell wrapper for local development
  • tests/ - Pytest-based tests

See Also

  • PROMPT.md for full requirements

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

devlogs-1.0.0.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

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

devlogs-1.0.0-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: devlogs-1.0.0.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for devlogs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 52ee5af9c646ccff1606c0829125942a228ed17480aaba62c0e10ea67c41d191
MD5 2b17cc493ece9701bc5e3d34a2a8cd32
BLAKE2b-256 ea1918f8dcba4a857fa0876acd4f5dc7c0b25d725faaed4371533c607bd8ae8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: devlogs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 36.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for devlogs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2f7a0c52feefe0b9adbb91c5e5fc59c0ad59e1b6fded41bf584882e5090293c
MD5 95ba96b233a68fb948ecce4d56fad071
BLAKE2b-256 4a25fc62bdfa6462faba698ea801439e432b0dd6eaeb717ccb487f40a6915551

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