From ccca3566cc00c22eed8659705e45386fa2101b5d Mon Sep 17 00:00:00 2001 From: Delgan <4193924+Delgan@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:57:59 +0100 Subject: [PATCH] Replace "notifiers" (seems unmaintained) with "apprise" in docs (#1251) --- README.md | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ccc88a22..9c95808e 100644 --- a/README.md +++ b/README.md @@ -363,26 +363,22 @@ for groups in logger.parse("file.log", pattern, cast=caster_dict): ### Exhaustive notifier -Loguru can easily be combined with the great [`notifiers`](https://github.com/notifiers/notifiers) library (must be installed separately) to receive an e-mail when your program fail unexpectedly or to send many other kind of notifications. +Loguru can easily be combined with the great [`apprise`](https://github.com/caronc/apprise) library (must be installed separately) to receive an e-mail when your program fail unexpectedly or to send many other kind of notifications. ```python -import notifiers +import apprise -params = { - "username": "you@gmail.com", - "password": "abc123", - "to": "dest@gmail.com" -} - -# Send a single notification -notifier = notifiers.get_notifier("gmail") -notifier.notify(message="The application is running!", **params) +# Define the configuration constants. +WEBHOOK_ID = "123456790" +WEBHOOK_TOKEN = "abc123def456" -# Be alerted on each error message -from notifiers.logging import NotificationHandler +# Prepare the object to send Discord notifications. +notifier = apprise.Apprise() +notifier.add(f"discord://{WEBHOOK_ID}/{WEBHOOK_TOKEN}") -handler = NotificationHandler("gmail", defaults=params) -logger.add(handler, level="ERROR") +# Install a handler to be alerted on each error. +# You can filter out logs from "apprise" itself to avoid recursive calls. +logger.add(notifier.notify, level="ERROR", filter={"apprise": False}) ```