Python SDK for LogDash logging and metrics service
Project description
LogDash Python SDK
The official Python SDK for LogDash - a simple and powerful logging and metrics service.
Installation
pip install logdash
Features
- Colorized console logging
- Remote log aggregation
- Metrics tracking
- Support for multiple log levels
- Fully Pythonic implementation
Usage
Basic Usage
from logdash import create_logdash
# Initialize LogDash with your API key
logdash = create_logdash({
"api_key": "your-api-key-here",
"host": "https://api.logdash.io", # optional, default value shown
"verbose": False # optional, default value shown
})
# Access the logger
logger = logdash["logger"]
logger.info("This is an info message")
logger.error("This is an error message")
logger.debug("This is a debug message")
# Log levels supported:
# - error
# - warn
# - info (also available as log())
# - http
# - verbose
# - debug
# - silly
# Access metrics
metrics = logdash["metrics"]
metrics.set("page_views", 100) # Set a metric value
metrics.mutate("user_count", 1) # Change a metric by a value (increment/decrement)
Local Development
If you don't provide an API key, logs will only be output locally and metrics will not be tracked:
from logdash import create_logdash
# Local only logger
logdash = create_logdash()
logdash["logger"].info("This will only be logged locally")
Complete Example
Check out the examples directory for more detailed examples.
#!/usr/bin/env python3
import time
from logdash import create_logdash
# Initialize LogDash
logdash = create_logdash({
"api_key": "your-api-key", # Replace with your actual API key
"verbose": True, # Enable verbose mode for development
})
logger = logdash["logger"]
metrics = logdash["metrics"]
# Log at different levels
logger.info("Application started")
logger.debug("Debug information")
logger.warn("Warning message")
logger.error("Error occurred")
# Track metrics
metrics.set("active_users", 100)
metrics.mutate("requests_count", 1)
Requirements
- Python 3.7+
- requests
- colorama
Development
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install development dependencies
pip install -e .
License
MIT
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
logdash-0.1.1.tar.gz
(8.9 kB
view details)
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
logdash-0.1.1-py3-none-any.whl
(11.5 kB
view details)
File details
Details for the file logdash-0.1.1.tar.gz.
File metadata
- Download URL: logdash-0.1.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8df749dcd0b1934c07e0430431ce817ff3410e8a675f5a59641bcdc065f0202f
|
|
| MD5 |
36d0e1e357e32787ed260109796d7e23
|
|
| BLAKE2b-256 |
de792bb8f8cf83c6f9da40ce8bf1f8bc82d409ab40aeaa29b305e649b0e3bc5a
|
File details
Details for the file logdash-0.1.1-py3-none-any.whl.
File metadata
- Download URL: logdash-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65244d259b7a7b6e8d091c3134b1cc38fdab6654b15dc2fea4cc032fed622947
|
|
| MD5 |
4203dc1ff9c3a428cb516c36a9f5b3a2
|
|
| BLAKE2b-256 |
ffbec84290e06ccb53409188a9d7b79aa095b27c967ceb4c4ba9ffd7eb3ce2e9
|