A package integrating loguru and apprise for logging and notifications
Project description
Logprise
Logprise provides a one-stop logger for your Python application by integrating loguru and apprise. It intercepts all standard logging calls and routes them through a unified interface. Above a configurable threshold, errors are automatically sent as alerts via Slack, Discord, email, or 100+ other services - no code changes needed.
Why Logprise?
Your script crashes at 3 AM. You want to know about it immediately, not when you check logs tomorrow. Logprise automatically captures errors and sends them to your notification service of choice.
Works with your existing code: Logprise intercepts standard Python logging calls and redirects them through loguru. No need to refactor your codebase or update third-party libraries.
from logprise import logger
import logging
logger.error("Payment processing failed") # You get notified
logging.error("Database connection lost") # Also notified (auto-intercepted)
logger.warning("High memory usage") # Silent (unless configured)
Installation
pip install logprise
Quick Start
Step 1: Configure notification service (create ~/.apprise file):
mailto://user:pass@gmail.com
Step 2: Use it in your code:
from logprise import logger
logger.info("Script started")
logger.error("This triggers a notification") # Sent when program exits or after 1 hour
That's it. Errors automatically trigger notifications. No configuration needed beyond setting up your notification service.
Configuration
Notification Services
Apprise supports 100+ services. Configure them in ~/.apprise (or other standard locations):
# Email
mailto://user:pass@gmail.com
# Slack
slack://tokenA/tokenB/tokenC/#channel
# Discord
discord://webhook_id/webhook_token
# Telegram
tgram://bot_token/chat_id
See Apprise's service list for all options.
You can also add services programmatically:
from logprise import appriser
appriser.add("mailto://user:pass@gmail.com")
appriser.add(["slack://token/...", "discord://webhook/..."])
Notification Level
Control which log levels trigger notifications:
from logprise import appriser
appriser.notification_level = "WARNING" # Notify on WARNING and above
appriser.notification_level = "CRITICAL" # Only critical issues
appriser.notification_level = 30 # Numeric levels work too
Default is ERROR (30).
Timing Control
Notifications batch to prevent spam. Control when they're sent:
from logprise import appriser
# Change flush interval (default: 3600 seconds)
appriser.flush_interval = 1800 # Send every 30 minutes
# Send immediately
appriser.send_notification()
# Clear pending notifications without sending
appriser.buffer.clear()
Notifications automatically flush when your program exits.
Use Cases
Long-running scripts:
from logprise import logger
for item in large_dataset:
try:
process(item)
except Exception as e:
logger.error(f"Failed processing {item}: {e}")
# Notification sent, script continues
Scheduled jobs:
from logprise import logger, appriser
appriser.notification_level = "INFO" # Get notified of completion too
def daily_backup():
logger.info("Backup started")
# ... backup logic ...
logger.info("Backup completed")
Monitoring critical sections:
from logprise import logger
if disk_usage > 90:
logger.critical(f"Disk usage at {disk_usage}%")
# Immediate notification on program exit
Works with third-party libraries:
from logprise import logger
import requests
import logging
# Third-party libraries using standard logging are automatically captured
response = requests.get("https://api.example.com")
# If requests logs an error, you'll be notified
# Your existing logging code works too
logging.error("Custom error from standard logging")
logger.error("Error from loguru")
# Both trigger notifications
How It Works
- Automatic interception: Logprise intercepts both loguru and standard library
logging, redirecting all logs through a unified interface - Smart batching: Messages accumulate until flush interval or program exit
- Exception capture: Uncaught exceptions are logged and trigger immediate notification
- Multiple services: Send to multiple notification services simultaneously
This means third-party libraries using standard logging will also trigger notifications when they log errors.
Advanced Features
Prevent handler removal:
from logprise import logger
logger.remove() # Logprise handler persists automatically
Tagging for routing:
from logprise import appriser
appriser.add("discord://webhook/...", tag=["critical"])
appriser.add("mailto://...", tag=["all"])
Custom notification format:
from logprise import appriser
from apprise import NotifyType, NotifyFormat
appriser.send_notification(
title="Production Alert",
notify_type=NotifyType.FAILURE,
body_format=NotifyFormat.MARKDOWN
)
Contributing
git clone https://github.com/svaningelgem/logprise.git
cd logprise
poetry install
poetry run pytest
Contributions welcome via pull requests.
License
MIT License - see LICENSE file for details.
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 logprise-1.3.3.tar.gz.
File metadata
- Download URL: logprise-1.3.3.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb371b9b44a1f47fe78c1f69549d1c028a60c50b8e4495cf787aa800848864be
|
|
| MD5 |
e28a8045c22eddc3006020d86258ae6e
|
|
| BLAKE2b-256 |
6a6f5aa9332a05d76616d9bac110f0c812354be1b8a509e0f6e97bea9734cb7c
|
Provenance
The following attestation bundles were made for logprise-1.3.3.tar.gz:
Publisher:
release.yml on svaningelgem/logprise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logprise-1.3.3.tar.gz -
Subject digest:
fb371b9b44a1f47fe78c1f69549d1c028a60c50b8e4495cf787aa800848864be - Sigstore transparency entry: 714947242
- Sigstore integration time:
-
Permalink:
svaningelgem/logprise@c41d563bdd15d7d02d2344ca161d9eab8601b210 -
Branch / Tag:
refs/tags/1.3.3 - Owner: https://github.com/svaningelgem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c41d563bdd15d7d02d2344ca161d9eab8601b210 -
Trigger Event:
push
-
Statement type:
File details
Details for the file logprise-1.3.3-py3-none-any.whl.
File metadata
- Download URL: logprise-1.3.3-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90c85b09ac7e1bf4fa0a035b0293c374a3af53c2c0de814e5299226f8f2a2bab
|
|
| MD5 |
fb2925ffc5994fedf8297c9036d7a55e
|
|
| BLAKE2b-256 |
507c090532ccc917d2693cc292a81c44bb7e8d273edb9e448d9182d56655f542
|
Provenance
The following attestation bundles were made for logprise-1.3.3-py3-none-any.whl:
Publisher:
release.yml on svaningelgem/logprise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logprise-1.3.3-py3-none-any.whl -
Subject digest:
90c85b09ac7e1bf4fa0a035b0293c374a3af53c2c0de814e5299226f8f2a2bab - Sigstore transparency entry: 714947249
- Sigstore integration time:
-
Permalink:
svaningelgem/logprise@c41d563bdd15d7d02d2344ca161d9eab8601b210 -
Branch / Tag:
refs/tags/1.3.3 - Owner: https://github.com/svaningelgem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c41d563bdd15d7d02d2344ca161d9eab8601b210 -
Trigger Event:
push
-
Statement type: