Преглед изворни кода

Right-size the adapter's log levels

Per-message payload dumps move to debug so one inbound message no
longer produces five INFO lines with full message bodies; dispatch
keeps a concise INFO line plus a debug object dump. Unauthorized-user
rejections become warnings, config validation failures errors, seed
failures warnings, and unknown event kinds / standalone close failures
downgrade to warnings. Also fix the copy-pasted 'event loop aborted'
wording in _dispatch_message_posted.
Paul Klumpp пре 1 недеља
родитељ
комит
42164fe606
1 измењених фајлова са 14 додато и 13 уклоњено
  1. 14 13
      adapter.py

+ 14 - 13
adapter.py

@@ -528,7 +528,7 @@ class ChattoAdapter(BasePlatformAdapter):
                 len(timeline_page.events),
             )
         except Exception as e:
-            logger.debug("Chatto: get room events failed for %s: %s", room_id, e)
+            logger.warning("Chatto: get room events failed for %s: %s", room_id, e)
 
     # ------------------------------------------------------------------ #
     # Realtime Event List
@@ -614,7 +614,7 @@ class ChattoAdapter(BasePlatformAdapter):
             return True
         if user.id in self.chatto_config.allowed_users.value:
             return True
-        logger.info(
+        logger.warning(
             "Chatto: rejecting message from unauthorized user '%s' (%s)",
             user.login,
             user.id,
@@ -833,7 +833,7 @@ class ChattoAdapter(BasePlatformAdapter):
             if not url:
                 # Videos are announced before transcoding finishes, so the
                 # signed URL can legitimately be missing on arrival.
-                logger.info(
+                logger.debug(
                     "Chatto: attachment '%s' has no asset URL yet, skipping",
                     filename,
                 )
@@ -906,15 +906,15 @@ class ChattoAdapter(BasePlatformAdapter):
         try:
             client = await self._require_client()
         except RuntimeError:
-            logger.warning("Chatto: chattolib event loop aborted - no client available")
+            logger.warning("Chatto: dropping message - no client available")
             return
-        logger.info("Chatto WS: 'message_posted' payload:%s", payload)
+        logger.debug("Chatto WS: 'message_posted' payload:%s", payload)
 
         message = await payload.fetch_message(client=client)
         if message is None or message.deleted_at:
             return
         message_body = message.body or ""
-        logger.info("message: %s", message)
+        logger.debug("message: %s", message)
 
         attachments = list(message.attachments or [])
         # A message carrying only an image/PDF has an empty body — dropping it
@@ -954,7 +954,7 @@ class ChattoAdapter(BasePlatformAdapter):
 
         room_kind = self._room_kinds.get(message.room_id)
 
-        logger.info("message_body: %s room_kind: %s", message_body, room_kind)
+        logger.debug("message_body: %s room_kind: %s", message_body, room_kind)
 
         # Membership commands ride in over DMs only: they change what the bot
         # listens to and must never reach the agent pipeline or the mention
@@ -985,7 +985,7 @@ class ChattoAdapter(BasePlatformAdapter):
                 )
                 return
 
-        logger.info("mentioned: %s", mentioned)
+        logger.debug("mentioned: %s", mentioned)
 
         # With require_mention off we see every message in the channel, including
         # ones plainly aimed at a named colleague. Answering those would be
@@ -1053,7 +1053,8 @@ class ChattoAdapter(BasePlatformAdapter):
         else:
             message_event.message_type = MessageType.TEXT
 
-        logger.info("Chatto: Dispatching MessageEvent to Hermes: %s", message_event)
+        logger.debug("Chatto: MessageEvent: %s", message_event)
+        logger.info("Chatto: dispatching message to Hermes")
         await self.handle_message(message_event)
         return
 
@@ -1109,7 +1110,7 @@ class ChattoAdapter(BasePlatformAdapter):
         if event.actor_id is None:
             return
 
-        logger.info("EVENT happened: '%s' from %s", event.kind, event.actor_id)
+        logger.debug("EVENT happened: '%s' from %s", event.kind, event.actor_id)
 
         if (event_payload := event.get("message_posted")) is not None:
             # Self-event filter — the actor_id on the envelope is authoritative
@@ -1147,7 +1148,7 @@ class ChattoAdapter(BasePlatformAdapter):
                 event.kind,
             )
         else:
-            logger.error("Chatto: unknown event kind: '%s'", event.kind)
+            logger.warning("Chatto: unknown event kind: '%s'", event.kind)
 
     async def _chattolib_event_loop(self) -> None:
         """Event loop using chattolib's stream_events.
@@ -2421,7 +2422,7 @@ async def hermes_standalone_sender_fn(
         try:
             await client.close()
         except Exception as exc:
-            logger.error(
+            logger.warning(
                 "Chatto standalone: error closing short-lived client (perhaps already closed): %s",
                 exc,
             )
@@ -2440,7 +2441,7 @@ def hermes_validate_config(config: PlatformConfig) -> bool:
         len(chatto_config.allowed_users.value) > 0
         and chatto_config.allow_all_users.value
     ):
-        logger.info(
+        logger.error(
             "Chatto: Conflicting configuration. Either use 'allowed_users' or 'allow_all_users' but not both."
         )
         return False