Python client library for DevStream logging service
Project description
DevStream Python Client
Python client library for sending logs to DevStream logging service.
Installation
pip install devstream-client
Or install from source:
cd client
pip install -e .
Quick Start
Basic Usage
from devstream_client import DevStreamClient
# Initialize client
client = DevStreamClient(
api_key="your-api-key",
app_key="my-app",
deployment_key="production",
base_url="http://localhost:8787" # or your production URL
)
# Send a simple log
client.log("Application started successfully")
# Send a log with tags
client.log_with_tags(
"User logged in",
user_id="12345",
level="info",
ip_address="192.168.1.1"
)
Python Logging Integration
import logging
from devstream_client import DevStreamHandler
# Create logger
logger = logging.getLogger("myapp")
logger.setLevel(logging.INFO)
# Add DevStream handler
handler = DevStreamHandler(
api_key="your-api-key",
app_key="my-app",
deployment_key="production",
base_url="http://localhost:8787" # or your production URL
)
logger.addHandler(handler)
# Use standard Python logging
logger.info("Application started")
logger.error("Something went wrong", exc_info=True)
Django Integration
Add to your Django settings:
# settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'devstream': {
'class': 'devstream_client.client.DevStreamHandler',
'api_key': 'your-api-key',
'app_key': 'my-django-app',
'deployment_key': os.environ.get('DEPLOYMENT', 'local'),
'base_url': 'http://localhost:8787', # or your production URL
},
},
'loggers': {
'django': {
'handlers': ['devstream'],
'level': 'INFO',
},
'myapp': {
'handlers': ['devstream'],
'level': 'DEBUG',
},
},
}
Configuration
Client Parameters
api_key(required): Your DevStream API keyapp_key(required): Application identifierdeployment_key(required): Deployment environment (e.g., 'local', 'dev', 'staging', 'production')base_url(optional): DevStream service URL (default: http://localhost:8787)
Tags
Tags are key-value pairs that help you filter and search logs. You can add tags in two ways:
- As a list of dictionaries:
client.log("User action", tags=[
{"name": "user_id", "value": "12345"},
{"name": "action", "value": "login"}
])
- As keyword arguments:
client.log_with_tags(
"User action",
user_id="12345",
action="login"
)
Features
- Simple API for sending logs
- Integration with Python's standard logging module
- Support for custom tags
- Automatic retry and error handling
- Django-ready configuration
License
MIT License
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 devstream_client-0.1.0.tar.gz.
File metadata
- Download URL: devstream_client-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f3c9fef320c5cd63d489c67cb93feff72d639c9c0efccd94e1f9d0b40324d1d
|
|
| MD5 |
f6aa95c31faa92c620ef01d81a8326b3
|
|
| BLAKE2b-256 |
02af0a13ee095c4e2754533d1da9b45339407d6e71063c07a4ef49fe98bf32cd
|
File details
Details for the file devstream_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: devstream_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca0dc5361113fc699de632b471bd5240bdf59994c49920a3dc50617f89b2e3ac
|
|
| MD5 |
8e2dce002c2c8188aaeb9e83bb9b0260
|
|
| BLAKE2b-256 |
bba94de0692497e8764e19101373033578773f533268ddb207cc22f098735374
|