18 lines
512 B
Python
18 lines
512 B
Python
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
|