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:
- Install
devlogs(pip install devlogsor add it torequirements.txt/pyproject.toml).- Add
DEVLOGS_OPENSEARCH_HOST,DEVLOGS_OPENSEARCH_PORT,DEVLOGS_OPENSEARCH_USER,DEVLOGS_OPENSEARCH_PASS, andDEVLOGS_INDEXto the project.envfile (or equivalent config). Defaults arelocalhost,9200,admin, anddevlogs-<projectname>.- Add devlogs hooks immediately at the beginning of the application (main entrypoint/startup module) to attach the handler:
from devlogs.handler import OpenSearchHandlerhandler = OpenSearchHandler(level=logging.INFO)logging.getLogger().addHandler(handler)logging.getLogger().setLevel(logging.INFO)- Run
devlogs init(inside the virtualenv if one is set up) and verify the index is healthy.- Ask the user if they want MCP set up; if yes, state which agent you are (
copilot,claude, orcodex) and rundevlogs initmcp <agent>.
OpenSearch Setup (Docker)
If you don't already have OpenSearch running locally:
- Install Docker (and Docker Compose) for your OS.
- Copy
docker-compose.example.yamltodocker-compose.yaml. - Change the OpenSearch password in the copied file.
- Start OpenSearch:
docker compose up -d
Quickstart
-
Install devlogs:
pip install devlogs
-
Start OpenSearch:
docker-compose up -d opensearch
Or point
DEVLOGS_OPENSEARCH_*at an existing cluster. -
Initialize indices/templates:
devlogs init -
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"}})
-
Tail logs from CLI:
devlogs tail --area web --follow
-
Search logs from CLI:
devlogs search --q "error" --area web
-
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.Handlerfor 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 UIdevlogs- Shell wrapper for local developmenttests/- Pytest-based tests
See Also
PROMPT.mdfor full requirements
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 devlogs-1.0.3.tar.gz.
File metadata
- Download URL: devlogs-1.0.3.tar.gz
- Upload date:
- Size: 55.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adcaffabfbf2ab029cf6ea76601cc446f394b5250ecf9c337098641ed184a7e1
|
|
| MD5 |
e79acc59cdfc34616597cb113f2dc9d3
|
|
| BLAKE2b-256 |
60cc7c3501b6667fe8c2151d9a889d2437b5848488bb852680c9e014cb3bf802
|
File details
Details for the file devlogs-1.0.3-py3-none-any.whl.
File metadata
- Download URL: devlogs-1.0.3-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97bfbb0c854c9f5aeb01cc273f66b98c77f368e72461da9440fe793306c1b8fd
|
|
| MD5 |
e0afdee1369b03c3ab431482f99fdd88
|
|
| BLAKE2b-256 |
3ad3c6c73fd8bb5e522bba28c3c86498cda43c5317e99a6ee439b3893ed001c0
|