Skip to main content

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"
)

# Attach structured JSON data to a log
client.log(
    "Order placed",
    tags=[{"name": "level", "value": "info"}],
    data={"order_id": 4823, "total": 19.99, "items": ["sku-1", "sku-2"]},
)

# data also works with the keyword-tag helper
client.log_with_tags(
    "Order placed",
    data={"order_id": 4823, "total": 19.99},
    level="info",
)

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 key
  • app_key (required): Application identifier
  • deployment_key (required): Deployment environment (e.g., 'local', 'dev', 'staging', 'production')
  • base_url (optional): DevStream service URL (default: http://localhost:8787)
  • timeout (optional): Per-request timeout in seconds (default: 5.0)
  • max_retries (optional): Automatic retries on connection errors and transient 5xx responses (default: 2)

Structured Data

Pass a data dictionary to attach arbitrary JSON to a log message. It is stored alongside the message and returned by the API and log viewer:

client.log("Payment failed", data={"amount": 50, "currency": "USD", "code": "card_declined"})

Tags

Tags are key-value pairs that help you filter and search logs. You can add tags in two ways:

  1. As a list of dictionaries:
client.log("User action", tags=[
    {"name": "user_id", "value": "12345"},
    {"name": "action", "value": "login"}
])
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devstream_client-0.2.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

devstream_client-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file devstream_client-0.2.0.tar.gz.

File metadata

  • Download URL: devstream_client-0.2.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for devstream_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0cd5b0c49ced02133f0ca74f9531ce41b8991cc29e9a8b1ad837b598b264fa93
MD5 18671830decc44a3d322ffe6bee1155d
BLAKE2b-256 7f4e2a7c37f342fea0b2500f6d9dc8d09074bba50d641d22d1cb834af41f6144

See more details on using hashes here.

File details

Details for the file devstream_client-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for devstream_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2025faad53300d4aabab7477dc83e68d96d5d32a74d85f6f42a110fc55c6ae5
MD5 5c3fc39ff045d6ce3e7ffe2b98eb9131
BLAKE2b-256 1125b62d507b80fc62cec16d82e1cb7dd3a755b3fe098076e0d49c97c13418d3

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