Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Suppress ReadTimeout exceptions due to frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanC committed Jun 19, 2024
1 parent 9e89063 commit 05c9d25
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions leash.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import dotenv
import httpx
from discord_webhook import DiscordEmbed, DiscordWebhook
from httpx import Response
from httpx import ReadTimeout, Response, TimeoutException
from loguru import logger
from loguru_discord import DiscordSink

Expand All @@ -31,7 +31,7 @@ def Start() -> None:

if url := environ.get("LOG_DISCORD_WEBHOOK_URL"):
logger.add(
DiscordSink(url),
DiscordSink(url, suppress=[ReadTimeout, TimeoutException]),
level=environ.get("LOG_DISCORD_WEBHOOK_LEVEL", "WARNING"),
backtrace=False,
)
Expand Down Expand Up @@ -124,6 +124,9 @@ def GetLeasesDHCPv4() -> list[dict[str, str]]:
res.raise_for_status()

leases = res.json()["rows"]
except ReadTimeout as e:
# Suppress ReadTimeout exceptions due to frequency
logger.opt(exception=e).info("Failed to fetch DHCPv4 Leases from OPNsense")
except Exception as e:
logger.opt(exception=e).error("Failed to fetch DHCPv4 Leases from OPNsense")

Expand Down

0 comments on commit 05c9d25

Please sign in to comment.