change log levels

This commit is contained in:
Josh Hawkins
2026-10-30 21:39:14 -05:00
parent b25b8a7294
commit cbd878481e
4 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ def build_report(
sections[name] = collect(ctx)
except Exception:
# a collector bug must cost one section, never the whole report
logger.warning("Analytics %s section failed", name, exc_info=True)
logger.debug("Analytics %s section failed", name, exc_info=True)
sections[name] = None
return AnalyticsReport.model_validate(
+2 -2
View File
@@ -33,7 +33,7 @@ def load_state(path: str = STATE_PATH) -> AnalyticsState | None:
except FileNotFoundError:
return None
except (OSError, ValueError):
logger.warning("Ignoring unreadable analytics state at %s", path)
logger.debug("Ignoring unreadable analytics state at %s", path)
return None
if not isinstance(data, dict):
@@ -48,7 +48,7 @@ def load_state(path: str = STATE_PATH) -> AnalyticsState | None:
or isinstance(last_attempt_at, bool)
or not isinstance(last_attempt_at, int | float)
):
logger.warning("Ignoring invalid analytics state at %s", path)
logger.debug("Ignoring invalid analytics state at %s", path)
return None
return AnalyticsState(install_id=install_id, last_attempt_at=float(last_attempt_at))
+3 -3
View File
@@ -34,7 +34,7 @@ def send_report(url: str, body: str) -> SendOutcome:
allow_redirects=False,
)
except requests.RequestException as err:
logger.warning("Unable to send the analytics report: %s", err)
logger.debug("Unable to send the analytics report: %s", err)
return SendOutcome.failed
status = response.status_code
@@ -43,12 +43,12 @@ def send_report(url: str, body: str) -> SendOutcome:
return SendOutcome.accepted
if status == 400:
logger.warning("The analytics report was rejected: %s", response.text[:200])
logger.debug("The analytics report was rejected: %s", response.text[:200])
return SendOutcome.rejected
if status == 429:
logger.debug("The analytics endpoint is rate limiting this install")
return SendOutcome.rate_limited
logger.warning("The analytics endpoint returned %s", status)
logger.debug("The analytics endpoint returned %s", status)
return SendOutcome.failed
+6 -2
View File
@@ -49,12 +49,16 @@ class TestSendReport(unittest.TestCase):
def test_logs_the_rejection_reason(self):
with (
post(400, "install_id: bad"),
self.assertLogs("frigate.analytics.transport", "WARNING") as logs,
self.assertLogs("frigate.analytics.transport", "DEBUG") as logs,
):
send_report(URL, "{}")
self.assertIn("install_id: bad", logs.output[0])
def test_a_network_error_fails_without_raising(self):
with post(side_effect=requests.ConnectionError("down")):
# the user can't act on a failed send, so it stays out of warnings
with (
post(side_effect=requests.ConnectionError("down")),
self.assertNoLogs("frigate.analytics.transport", "WARNING"),
):
self.assertIs(send_report(URL, "{}"), SendOutcome.failed)