Skip to main content

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.txt 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logprise-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logprise-1.0.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file logprise-1.0.0.tar.gz.

File metadata

  • Download URL: logprise-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.1.0-31-amd64

File hashes

Hashes for logprise-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d12dbfcfff463fa553cdf96f25af822100cbaaaa3412306f8ea90a9e9640b8ff
MD5 7685c955ba1f5fcee88d21edc1db2571
BLAKE2b-256 a33727099f890e3eab17e0125d1dc39a33b302687ddd01e908ae1fc640361272

See more details on using hashes here.

File details

Details for the file logprise-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: logprise-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.1.0-31-amd64

File hashes

Hashes for logprise-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51f4e8a004687e1422af494cc47a1c5cd97bb1650329921d95fa45223ee337d5
MD5 ae9c057335afbc15b0e0c76e20c544f0
BLAKE2b-256 4938ee994ca229b71d1323eecd3cf5d4d991d02ec710ec5dd7de150d8e69d163

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page