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) sections[name] = collect(ctx)
except Exception: except Exception:
# a collector bug must cost one section, never the whole report # 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 sections[name] = None
return AnalyticsReport.model_validate( return AnalyticsReport.model_validate(
+2 -2
View File
@@ -33,7 +33,7 @@ def load_state(path: str = STATE_PATH) -> AnalyticsState | None:
except FileNotFoundError: except FileNotFoundError:
return None return None
except (OSError, ValueError): except (OSError, ValueError):
logger.warning("Ignoring unreadable analytics state at %s", path) logger.debug("Ignoring unreadable analytics state at %s", path)
return None return None
if not isinstance(data, dict): 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 isinstance(last_attempt_at, bool)
or not isinstance(last_attempt_at, int | float) 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 None
return AnalyticsState(install_id=install_id, last_attempt_at=float(last_attempt_at)) 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, allow_redirects=False,
) )
except requests.RequestException as err: 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 return SendOutcome.failed
status = response.status_code status = response.status_code
@@ -43,12 +43,12 @@ def send_report(url: str, body: str) -> SendOutcome:
return SendOutcome.accepted return SendOutcome.accepted
if status == 400: 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 return SendOutcome.rejected
if status == 429: if status == 429:
logger.debug("The analytics endpoint is rate limiting this install") logger.debug("The analytics endpoint is rate limiting this install")
return SendOutcome.rate_limited return SendOutcome.rate_limited
logger.warning("The analytics endpoint returned %s", status) logger.debug("The analytics endpoint returned %s", status)
return SendOutcome.failed return SendOutcome.failed
+6 -2
View File
@@ -49,12 +49,16 @@ class TestSendReport(unittest.TestCase):
def test_logs_the_rejection_reason(self): def test_logs_the_rejection_reason(self):
with ( with (
post(400, "install_id: bad"), post(400, "install_id: bad"),
self.assertLogs("frigate.analytics.transport", "WARNING") as logs, self.assertLogs("frigate.analytics.transport", "DEBUG") as logs,
): ):
send_report(URL, "{}") send_report(URL, "{}")
self.assertIn("install_id: bad", logs.output[0]) self.assertIn("install_id: bad", logs.output[0])
def test_a_network_error_fails_without_raising(self): 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) self.assertIs(send_report(URL, "{}"), SendOutcome.failed)