mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-19 09:38:21 +08:00
🐛 fix log not escaped in forward driver
This commit is contained in:
parent
049d14295e
commit
cfdebb30b7
@ -9,18 +9,19 @@ import signal
|
||||
import asyncio
|
||||
import threading
|
||||
from dataclasses import dataclass
|
||||
from typing import Set, List, cast, Union, Optional, Callable, Awaitable
|
||||
from typing import Set, List, Union, Callable, Optional, Awaitable, cast
|
||||
|
||||
import aiohttp
|
||||
from yarl import URL
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot.utils import escape_tag
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.utils import escape_tag
|
||||
from nonebot.config import Env, Config
|
||||
from nonebot.drivers import (ForwardDriver, HTTPPollingSetup, WebSocketSetup,
|
||||
HTTPRequest, WebSocket as BaseWebSocket)
|
||||
from nonebot.drivers import WebSocket as BaseWebSocket
|
||||
from nonebot.drivers import (HTTPRequest, ForwardDriver, WebSocketSetup,
|
||||
HTTPPollingSetup)
|
||||
|
||||
STARTUP_FUNC = Callable[[], Awaitable[None]]
|
||||
SHUTDOWN_FUNC = Callable[[], Awaitable[None]]
|
||||
@ -242,8 +243,8 @@ class Driver(ForwardDriver):
|
||||
setup_ = setup
|
||||
except Exception as e:
|
||||
logger.opt(colors=True, exception=e).error(
|
||||
f"<r><bg #f8bbd0>Error while parsing setup {setup!r}.</bg #f8bbd0></r>"
|
||||
)
|
||||
"<r><bg #f8bbd0>Error while parsing setup "
|
||||
f"{escape_tag(repr(setup))}.</bg #f8bbd0></r>")
|
||||
await asyncio.sleep(3)
|
||||
continue
|
||||
|
||||
@ -324,8 +325,8 @@ class Driver(ForwardDriver):
|
||||
setup_ = setup
|
||||
except Exception as e:
|
||||
logger.opt(colors=True, exception=e).error(
|
||||
f"<r><bg #f8bbd0>Error while parsing setup {setup!r}.</bg #f8bbd0></r>"
|
||||
)
|
||||
"<r><bg #f8bbd0>Error while parsing setup "
|
||||
f"{escape_tag(repr(setup))}.</bg #f8bbd0></r>")
|
||||
await asyncio.sleep(3)
|
||||
continue
|
||||
|
||||
|
@ -13,26 +13,27 @@ FastAPI 驱动适配
|
||||
import asyncio
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from typing import List, cast, Union, Optional, Callable, Awaitable
|
||||
from typing import List, Union, Callable, Optional, Awaitable, cast
|
||||
|
||||
import httpx
|
||||
import uvicorn
|
||||
from pydantic import BaseSettings
|
||||
from fastapi.responses import Response
|
||||
from websockets.exceptions import ConnectionClosed
|
||||
from fastapi import status, Request, FastAPI, HTTPException
|
||||
from fastapi import FastAPI, Request, HTTPException, status
|
||||
from starlette.websockets import WebSocket as FastAPIWebSocket
|
||||
from starlette.websockets import WebSocketState, WebSocketDisconnect
|
||||
from websockets.legacy.client import Connect, WebSocketClientProtocol
|
||||
from starlette.websockets import (WebSocketState, WebSocketDisconnect, WebSocket
|
||||
as FastAPIWebSocket)
|
||||
|
||||
from nonebot.config import Env
|
||||
from nonebot.log import logger
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot.utils import escape_tag
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.config import Env, Config as NoneBotConfig
|
||||
from nonebot.drivers import (ReverseDriver, ForwardDriver, HTTPPollingSetup,
|
||||
WebSocketSetup, HTTPRequest, WebSocket as
|
||||
BaseWebSocket)
|
||||
from nonebot.utils import escape_tag
|
||||
from nonebot.config import Config as NoneBotConfig
|
||||
from nonebot.drivers import WebSocket as BaseWebSocket
|
||||
from nonebot.drivers import (HTTPRequest, ForwardDriver, ReverseDriver,
|
||||
WebSocketSetup, HTTPPollingSetup)
|
||||
|
||||
HTTPPOLLING_SETUP = Union[HTTPPollingSetup,
|
||||
Callable[[], Awaitable[HTTPPollingSetup]]]
|
||||
@ -357,8 +358,8 @@ class Driver(ReverseDriver, ForwardDriver):
|
||||
setup_ = setup
|
||||
except Exception as e:
|
||||
logger.opt(colors=True, exception=e).error(
|
||||
f"<r><bg #f8bbd0>Error while parsing setup {setup!r}.</bg #f8bbd0></r>"
|
||||
)
|
||||
"<r><bg #f8bbd0>Error while parsing setup "
|
||||
f"{escape_tag(repr(setup))}.</bg #f8bbd0></r>")
|
||||
await asyncio.sleep(3)
|
||||
continue
|
||||
|
||||
@ -422,8 +423,8 @@ class Driver(ReverseDriver, ForwardDriver):
|
||||
setup_ = setup
|
||||
except Exception as e:
|
||||
logger.opt(colors=True, exception=e).error(
|
||||
f"<r><bg #f8bbd0>Error while parsing setup {setup!r}.</bg #f8bbd0></r>"
|
||||
)
|
||||
"<r><bg #f8bbd0>Error while parsing setup "
|
||||
f"{escape_tag(repr(setup))}.</bg #f8bbd0></r>")
|
||||
await asyncio.sleep(3)
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user