A package integrating loguru and apprise for logging and notifications
Project description
Logprise
Logprise is a Python package that seamlessly integrates loguru and apprise to provide unified logging and notification capabilities. It allows you to automatically send notifications when specific log levels are triggered, making it perfect for monitoring applications and getting alerts when important events occur.
Features
- Unified logging interface that captures both standard logging and loguru logs
- Automatic notification delivery based on configurable log levels
- Batched notifications to prevent notification spam
- Flexible configuration through apprise's extensive notification service support
- Easy integration with existing Python applications
Installation
pip install logprise
Or if you're using Poetry:
poetry add logprise
Quick Start
Here's a simple example of how to use Logprise:
from logprise import logger
# Your logs will automatically trigger notifications
logger.info("This won't trigger a notification")
logger.warning("This won't trigger a notification")
logger.error("This will trigger a notification") # Default is ERROR level
# Notifications are automatically sent when your program exits
Configuration
Notification Services
Logprise uses Apprise for notifications, which supports a wide range of notification services. Create an .apprise file in one of the default configuration paths:
~/.apprise~/.config/apprise
Example configuration:
mailto://user:pass@gmail.com
tgram://bot_token/chat_id
slack://tokenA/tokenB/tokenC/#channel
See Apprise's configuration guide for the full list of supported services and their configuration.
Notification Levels
You can set the minimum log level that triggers notifications:
from logprise import appriser, logger
# Using string level names
appriser.notification_level = "WARNING" # or "DEBUG", "INFO", "ERROR", "CRITICAL"
# Using integer level numbers
appriser.notification_level = 30 # WARNING level
# Using loguru Level objects
appriser.notification_level = logger.level("ERROR")
Manual Notification Control
While notifications are sent automatically when your program exits, you can control them manually:
from logprise import appriser
# Clear the notification buffer
appriser.buffer.clear()
# Send notifications immediately
appriser.send_notification()
Contributing
To contribute to the project:
# Clone the repository
git clone https://github.com/yourusername/logprise.git
cd logprise
# Install dependencies
poetry install
# Run tests
poetry run pytest
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the 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.0.1.tar.gz.
File metadata
- Download URL: logprise-1.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d10d6881644a90f8321b7b2c2d0bb707bbec9dca06ed9ec4530738011691f19b
|
|
| MD5 |
71f5d327093cf72a58a82998e6931f15
|
|
| BLAKE2b-256 |
af21b056aa836812379db7dbe72ca049ea61cd45e66a6c58ad30d69ede1459bb
|
Provenance
The following attestation bundles were made for logprise-1.0.1.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.0.1.tar.gz -
Subject digest:
d10d6881644a90f8321b7b2c2d0bb707bbec9dca06ed9ec4530738011691f19b - Sigstore transparency entry: 173632820
- Sigstore integration time:
-
Permalink:
svaningelgem/logprise@a2e1585b98ed27e2e31da4004b1df2f9bbbb1ecc -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/svaningelgem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a2e1585b98ed27e2e31da4004b1df2f9bbbb1ecc -
Trigger Event:
push
-
Statement type:
File details
Details for the file logprise-1.0.1-py3-none-any.whl.
File metadata
- Download URL: logprise-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16fad431f47f79c12c36a1e5cb1f7e17ddd31eae800f0bad554fa0ae7861dfe1
|
|
| MD5 |
6e70ee2d5bd4eb43da1850475ab3ed3d
|
|
| BLAKE2b-256 |
d9d3c31ecc3d3836622924be67ddbaf30403f5d4ad8e7ee20c58c55970e48dee
|
Provenance
The following attestation bundles were made for logprise-1.0.1-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.0.1-py3-none-any.whl -
Subject digest:
16fad431f47f79c12c36a1e5cb1f7e17ddd31eae800f0bad554fa0ae7861dfe1 - Sigstore transparency entry: 173632822
- Sigstore integration time:
-
Permalink:
svaningelgem/logprise@a2e1585b98ed27e2e31da4004b1df2f9bbbb1ecc -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/svaningelgem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a2e1585b98ed27e2e31da4004b1df2f9bbbb1ecc -
Trigger Event:
push
-
Statement type: