Add gotify handler
This commit is contained in:
parent
a053aca70a
commit
ce5031b64f
1 changed files with 18 additions and 0 deletions
18
gallery/logging_handlers.py
Normal file
18
gallery/logging_handlers.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import logging
|
||||
|
||||
import requests
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class GotifyHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
log_entry = self.format(record)
|
||||
try:
|
||||
requests.post(
|
||||
settings.GOTIFY_URL,
|
||||
headers={"X-Gotify-Key": settings.GOTIFY_TOKEN},
|
||||
json={"message": log_entry, "priority": 5, "title": "Gallery Error"},
|
||||
timeout=5,
|
||||
)
|
||||
except requests.exceptions.RequestException:
|
||||
pass
|
Loading…
Add table
Reference in a new issue