Push logs from your Python app to the Sentry dashboard — AI-powered service health monitoring
Project description
Sentry Logger SDK (Python)
Push logs from your Python app to the Sentry dashboard.
Installation
pip install sentry-logger
# or from the repo:
pip install ./sdk/python
Quick Start — CLI + Browser OAuth
sentry-logger init --app-name "my-service" --dsn "http://localhost:9000"
What happens:
- CLI requests a device session from the backend
- Browser opens your sign-in page
- Sign in with Google — your app is registered and an API key is created
- CLI polls and stores credentials in
~/.sentry_logger/config.json
Check the currently linked app:
sentry-logger status
SDK Usage
from sentry_logger import init
# Reads api_key and dsn from ~/.sentry_logger/config.json
init()
import logging
logging.info("Hello from my app")
logging.error("Something went wrong")
Explicit configuration:
from sentry_logger import init
init(
api_key="sk_...",
dsn="http://localhost:9000", # your backend URL
)
Environment Variables
| Variable | Default | Description |
|---|---|---|
LOGSENTRY_URL |
http://localhost:9000 |
Backend ingest URL base |
FastAPI Example
import logging
from fastapi import FastAPI
from sentry_logger import init
app = FastAPI()
@app.on_event("startup")
def setup_logging() -> None:
init()
logging.getLogger(__name__).info("Sentry SDK initialized")
Configuration Reference
| Parameter | Default | Description |
|---|---|---|
api_key |
— | API key (sk_...). If omitted, loaded from CLI config |
dsn |
— | Ingest URL. Falls back to LOGSENTRY_URL env or http://localhost:8001 |
batch_size |
50 |
Send logs when buffer reaches this size |
flush_interval_seconds |
5.0 |
Auto-flush buffer after this many seconds |
Log Format
The SDK formats logs in the standard Python logging format. The backend parses:
2024-01-01 10:00:00,123 [INFO] [ServiceName]: Log message here
The ServiceName in brackets is used to group logs by service in the dashboard.
Use Python logger names to map to service names:
logger = logging.getLogger("PaymentService")
logger.info("Payment processed")
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
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 sentry_logger-0.1.0.tar.gz.
File metadata
- Download URL: sentry_logger-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84188b26e75c5a2cc522df1ad8afa690974fa877defd8b1901a8727d4cece54c
|
|
| MD5 |
ca06e68ad3004e4a99547b7768f9c287
|
|
| BLAKE2b-256 |
9831b771ed21d794537fdd93eda3df1bf3beeaea590e13577f66bd712f7b02d1
|
File details
Details for the file sentry_logger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sentry_logger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
100cc6ed13b7dfb5bc0144849adb655abb1057629b30570ef864c81a956358f3
|
|
| MD5 |
4d5628bfa156e627c23f04fbd6e18ae9
|
|
| BLAKE2b-256 |
186827e8f1e39f907992765bdb8bc467aae4478a782d859f716c506474e0258d
|