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 — zero code changes required.
Installation
pip install sentry-logger
Step 1 — Link your app (one-time)
sentry-logger init --app-name "my-service"
This opens a browser sign-in, registers your app, and saves credentials to
~/.sentry_logger/config.json. Check the linked app anytime with:
sentry-logger status
Step 2 — Add one line to main.py
from sentry_logger import init
init() # that's it — nothing else to change anywhere
After this single call, everything flows to Sentry automatically:
| Source | Captured? |
|---|---|
logging.info/warning/error/critical(...) in any module |
✅ |
print() anywhere in your app |
✅ |
| Uvicorn / Gunicorn request logs | ✅ |
| Unhandled exceptions (crashes) | ✅ |
You do not need to add logging.xxx() calls to individual functions or routes.
FastAPI example (zero changes to routes)
from sentry_logger import init
init() # must be before FastAPI import so uvicorn loggers are hooked
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"} # uvicorn logs this request automatically
@app.get("/items/{item_id}")
def read_item(item_id: int):
print("processing item") # print() is also captured
return {"item_id": item_id}
How it works
init() attaches to the root Python logger, which means every library and
module in your app already propagates logs to it. It also:
- Redirects
stdout/stderrthrough logging soprint()is captured - Installs a
sys.excepthookto log unhandled exceptions asCRITICAL - Flushes batches every 5 seconds or every 50 log lines (configurable)
Service grouping
Name your loggers after services to group them in the dashboard:
import logging
logger = logging.getLogger("PaymentService")
logger.warning("Payment retry attempt") # shows under "PaymentService" tab
Uvicorn access logs appear under the uvicorn.access service group automatically.
Configuration reference
| Parameter | Default | Description |
|---|---|---|
api_key |
— | API key (sk_...). If omitted, loaded from CLI config |
dsn |
— | Backend URL. Falls back to SENTRY_INGEST_URL env or production endpoint |
batch_size |
50 |
Send when buffer reaches this size |
flush_interval_seconds |
5.0 |
Auto-flush interval in seconds |
redirect_print |
True |
Capture print() / stdout / stderr |
capture_exceptions |
True |
Log unhandled crashes as CRITICAL |
Explicit configuration
from sentry_logger import init
init(
api_key="sk_...",
dsn="http://localhost:9000",
redirect_print=True, # default
capture_exceptions=True, # default
)
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.3.tar.gz.
File metadata
- Download URL: sentry_logger-0.1.3.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c81f3ba684fe178ff7cad0ae42c99d1284c59cfd5a1da1f969d9c2dacc0ea258
|
|
| MD5 |
cab858ddbb5261a9633c833bee2a4781
|
|
| BLAKE2b-256 |
710550658735258f40693b6541c53fa81ac577dd03b121f79ad6d7ef52a0056c
|
File details
Details for the file sentry_logger-0.1.3-py3-none-any.whl.
File metadata
- Download URL: sentry_logger-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.8 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 |
fea1ce346cc63a34a158623a5733c07c3bce3b6c109d06c6554b5fe52e359865
|
|
| MD5 |
b2417761a61f9b1556792de2c5d31e4a
|
|
| BLAKE2b-256 |
5d7cc3f96b0431b1f6f0d75240efc4ab91fa02d5f2762595fb0eb008a0c0ec3b
|