Demote Signal receipt/typing/sync spam from INFO to DEBUG
signalbot logs every received envelope at INFO via `[Raw Message] {json}`. On a
busy account the delivery/read receipts, typing indicators, and read-sync
messages flood journald hard enough to rotate the journal down to ~1 minute,
burying real traffic and making failures impossible to debug after the fact.
Add a logging filter on the `signalbot` logger that suppresses content-free
envelopes (anything without a `dataMessage`) at INFO, while still emitting them
if the logger is explicitly set to DEBUG. Real message content stays at INFO.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,24 @@ logging.basicConfig(
|
||||
)
|
||||
log = logging.getLogger("signal-bot")
|
||||
|
||||
|
||||
class _RawReceiptNoiseFilter(logging.Filter):
|
||||
"""signalbot logs every received envelope at INFO via `[Raw Message] {json}`.
|
||||
On a busy account that's a flood of delivery/read receipts, typing indicators,
|
||||
and read-sync messages that rotates the journal down to ~1 minute and buries
|
||||
real traffic. Suppress the content-free envelopes (anything without a
|
||||
`dataMessage`) unless the signalbot logger is explicitly set to DEBUG — so they
|
||||
stay capturable when you actually want to debug raw traffic, but don't spam INFO."""
|
||||
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
msg = record.getMessage()
|
||||
if msg.startswith("[Raw Message] ") and '"dataMessage"' not in msg:
|
||||
return logging.getLogger("signalbot").isEnabledFor(logging.DEBUG)
|
||||
return True
|
||||
|
||||
|
||||
logging.getLogger("signalbot").addFilter(_RawReceiptNoiseFilter())
|
||||
|
||||
# (group_id, sender) -> {"b64": ..., "time": monotonic}. Keyed per sender so a
|
||||
# stranger's later video doesn't silently become the target of your /speed or
|
||||
# /rev; _get_video falls back to the group's latest video when you have none.
|
||||
|
||||
Reference in New Issue
Block a user