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.

Agent Instructions (Copy/Paste)

Please do the following in this project:

  1. Install devlogs (pip install devlogs or add it to requirements.txt/pyproject.toml).
  2. Add DEVLOGS_OPENSEARCH_HOST, DEVLOGS_OPENSEARCH_PORT, DEVLOGS_OPENSEARCH_USER, DEVLOGS_OPENSEARCH_PASS, and DEVLOGS_INDEX to the project .env file (or equivalent config). Defaults are localhost, 9200, admin, and devlogs-<projectname>.
  3. Add devlogs hooks immediately at the beginning of the application (main entrypoint/startup module) to attach the handler:
    • from devlogs.handler import OpenSearchHandler
    • handler = OpenSearchHandler(level=logging.INFO)
    • logging.getLogger().addHandler(handler)
    • logging.getLogger().setLevel(logging.INFO)
  4. Run devlogs init (inside the virtualenv if one is set up) and verify the index is healthy.
  5. Ask the user if they want MCP set up; if yes, state which agent you are (copilot, claude, or codex) and run devlogs initmcp <agent>.

OpenSearch Setup (Docker)

If you don't already have OpenSearch running locally:

  1. Install Docker (and Docker Compose) for your OS.
  2. Copy docker-compose.example.yaml to docker-compose.yaml.
  3. Change the OpenSearch password in the copied file.
  4. Start OpenSearch:
    docker compose up -d
    

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/
    

MCP Agent Setup

If you want MCP set up, identify your agent type and run the matching command from your project root:

devlogs initmcp copilot
devlogs initmcp claude
devlogs initmcp codex
devlogs initmcp all

This writes MCP config files in the standard locations:

  • Claude: .mcp.json
  • Copilot (VS Code): .vscode/mcp.json
  • Codex: ~/.codex/config.toml

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.1.0.tar.gz (57.1 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.1.0-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for devlogs-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3ba1abe83a25b7ae3c9d834a604c7f4b8cfa84048465e579305f84d75a4999c0
MD5 4c548d6a5f9419388f1c22c8a4f9ca63
BLAKE2b-256 99f8ca3d5cd38e5fb0ed72d974db5db319eade261214754769b360d8126dea08

See more details on using hashes here.

File details

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

File metadata

  • Download URL: devlogs-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d63dd7e57451a802e562535d98f7e891c0c532c9fc25699c386b482c85d3495
MD5 dc450545b72806bbfb0479d5eaa91e3b
BLAKE2b-256 60f8aa7aab98ecbf75eea9572cbf01ffd8e810bcba8c151c687dc72171516747

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