fix(weixin): silence polling request logs

Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
This commit is contained in:
Lanre Shittu authored and chengyongru committed 2026-09-27 19:00:51 +08:00
1 parent d9aa7cdda4
commit db6ef4d674
2 files changed
+19 -1

No files matched your search

+2
View File
@@ -37,6 +37,7 @@ from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir, get_runtime_subdir from nanobot.config.paths import get_media_dir, get_runtime_subdir
from nanobot.config.schema import Base from nanobot.config.schema import Base
from nanobot.utils.logging_bridge import redirect_lib_logging
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Protocol constants (from openclaw-weixin types.ts) # Protocol constants (from openclaw-weixin types.ts)
@@ -996,6 +997,7 @@ class WeixinChannel(BaseChannel):
self._client = None self._client = None
async def start(self) -> None: async def start(self) -> None:
redirect_lib_logging("httpx", level="WARNING")
self._running = True self._running = True
self._next_poll_timeout_s = self.config.poll_timeout self._next_poll_timeout_s = self.config.poll_timeout
self._client = self._new_http_client( self._client = self._new_http_client(
@@ -3,7 +3,7 @@ from __future__ import annotations
import asyncio import asyncio
import json import json
import time import time
from unittest.mock import AsyncMock from unittest.mock import AsyncMock, Mock
import httpx import httpx
import pytest import pytest
@@ -74,6 +74,22 @@ def test_reply_progress_opt_in_enables_progress_transport() -> None:
assert config.send_tool_hints is True assert config.send_tool_hints is True
@pytest.mark.asyncio
async def test_start_suppresses_httpx_polling_logs(monkeypatch) -> None:
channel = _channel(token="bot-token")
redirect = Mock()
monkeypatch.setattr("nanobot.channels.weixin.runtime.redirect_lib_logging", redirect)
monkeypatch.setattr(channel, "_notify_lifecycle", AsyncMock())
async def poll_once() -> None:
channel._running = False
monkeypatch.setattr(channel, "_poll_once", poll_once)
await channel.start()
redirect.assert_called_once_with("httpx", level="WARNING")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("section", "send_progress", "send_tool_hints"), ("section", "send_progress", "send_tool_hints"),
[ [