-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace "notifiers" (seems unmaintained) with "apprise" in docs (#1251)
- Loading branch information
Showing
1 changed file
with
11 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"password": "abc123", | ||
"to": "[email protected]" | ||
} | ||
|
||
# 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}) | ||
``` | ||
|
||
<s> | ||
|