Developer-focused logging library for Python with OpenSearch integration.
Project description
devlogs
A developer-focused logging library for Python based on OpenSearch.
Step 1: Get OpenSearch running
If you don't have OpenSearch running and you want to stand one up:
- 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
Step 2: Copy/paste these instructions into your coding agent
Please do the following in this project:
- Install
devlogsas a dev dependency (pip install devlogsor add it torequirements-dev.txt/pyproject.tomloptional dependencies).- 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 at the beginning of the application (main entrypoint/startup module), wrapped in an environment check so it only runs in development:
import os if os.getenv("ENVIRONMENT") != "production": from devlogs.handler import OpenSearchHandler handler = 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>.
Step 3: Use devlogs
- Run
devlogs initmcp <agent>to set up the MCP server. - Then run
devlogs tailto see the last logs, ordevlogs tail -fto follow along - Finally, ask your agent to query devlogs for errors. Watch it solve problems on its own!
If you want to install it by hand
-
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 (development only):
import os import logging # Only enable devlogs in development if os.getenv("ENVIRONMENT") != "production": from devlogs.handler import OpenSearchHandler logging.getLogger().addHandler(OpenSearchHandler(level=logging.DEBUG)) logging.getLogger().setLevel(logging.DEBUG) logging.info("Hello from devlogs!")
-
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)
Jenkins Integration
Stream Jenkins build logs to OpenSearch using a standalone binary:
pipeline {
agent any
environment {
DEVLOGS_OPENSEARCH_URL = credentials('devlogs-opensearch-url')
DEVLOGS_BINARY_URL = credentials('devlogs-binary-url')
}
stages {
stage('Build') {
steps {
sh 'curl -sL $DEVLOGS_BINARY_URL -o /tmp/devlogs && chmod +x /tmp/devlogs'
sh '/tmp/devlogs jenkins attach --background'
sh 'make build'
}
}
}
post {
always { sh '/tmp/devlogs jenkins stop || true' }
}
}
Build the binary with ./build-standalone.sh and host it somewhere accessible. See HOWTO-JENKINS.md for setup details.
Configuration
Environment Variables
- OpenSearch connection:
DEVLOGS_OPENSEARCH_HOST,DEVLOGS_OPENSEARCH_PORT,DEVLOGS_OPENSEARCH_USER,DEVLOGS_OPENSEARCH_PASS - OpenSearch URL shortcut:
DEVLOGS_OPENSEARCH_URL(e.g.,https://user:pass@host:9200/index) - SSL/TLS:
DEVLOGS_OPENSEARCH_VERIFY_CERTS,DEVLOGS_OPENSEARCH_CA_CERT - 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.
CLI Options
Use --url to specify connection details without a .env file:
devlogs --url 'https://admin:pass@host:9200/myindex' tail
Use --env to load from a specific .env file:
devlogs --env /path/to/.env diagnose
URL Builder
Use devlogs mkurl to interactively create a properly URL-encoded connection string:
devlogs mkurl
# Outputs the URL in three formats:
# 1. Bare URL (for --url flag)
# 2. Single DEVLOGS_OPENSEARCH_URL variable
# 3. Individual .env variables
This is especially useful for passwords containing special characters like !, @, #, which must be URL-encoded.
See HOWTO-CLI.md for complete CLI reference.
Production Deployment
Devlogs is a development tool. The examples above show how to conditionally enable it using an environment check. You can also make it an optional dependency:
# pyproject.toml
[project.optional-dependencies]
dev = ["devlogs>=1.1.0"]
Install with pip install ".[dev]" in development, pip install . in production.
Project Structure
src/devlogs/- Python library, CLI, MCP server, and web UIbrowser/- Browser/npm package for frontend loggingdevlogs- Shell wrapper for local developmenttests/- Pytest-based testsdist/- Built packages and standalone binary
Publishing
# Release to all platforms (PyPI, npm, GitHub)
./publish/release.sh
# Bump version and release
./publish/release.sh --bump-patch
# Preview release
./publish/release.sh --dry-run
See publish/RELEASING.md for detailed publishing instructions.
See Also
- HOWTO-CLI.md - Complete CLI reference
- HOWTO.md - Integration guide
- HOWTO-JENKINS.md - Jenkins setup
- HOWTO-MCP.md - MCP agent setup
- HOWTO-UI.md - Web UI guide
- publish/RELEASING.md - Publishing guide
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.1.2.tar.gz.
File metadata
- Download URL: devlogs-1.1.2.tar.gz
- Upload date:
- Size: 73.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b7ae29f2916ec36d302a1ff1f9d28206ea2ad3add98d20f2d2f854318558bb
|
|
| MD5 |
daa7406b1f341053de2dfb3f3b5d5a6c
|
|
| BLAKE2b-256 |
7011b0e900c5e60b4dd86d8f57cd7c0fd2a4d9384b640cf939f9584f623e714b
|
File details
Details for the file devlogs-1.1.2-py3-none-any.whl.
File metadata
- Download URL: devlogs-1.1.2-py3-none-any.whl
- Upload date:
- Size: 54.5 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 |
f5f2e2d8286e5cd40ecd7ea1e8c17152688132e975b96ae7eb4316c2f5127b20
|
|
| MD5 |
98abf0748977710317b3245fadfff86a
|
|
| BLAKE2b-256 |
fa0431a5748007962b3601efad8a852c286c9b81332bcb40a6b90518c17b1236
|