From 6ed87f1910ae7106a52d8aa796560970565c82b4 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Fri, 24 Dec 2021 15:04:18 +0800 Subject: [PATCH] :loud_sound: add trace logs --- nonebot/__init__.py | 2 ++ nonebot/dependencies/__init__.py | 6 ++++++ nonebot/matcher.py | 7 ++++++- poetry.lock | 8 ++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/nonebot/__init__.py b/nonebot/__init__.py index 78f7fc39..74811e10 100644 --- a/nonebot/__init__.py +++ b/nonebot/__init__.py @@ -216,11 +216,13 @@ def _resolve_combine_expr(obj_str: str) -> Type[Driver]: drivers[0], "Driver", default_prefix="nonebot.drivers." ) if len(drivers) == 1: + logger.trace(f"Detected driver {DriverClass} with no mixins.") return DriverClass mixins = [ _resolve_dot_notation(mixin, "Mixin", default_prefix="nonebot.drivers.") for mixin in drivers[1:] ] + logger.trace(f"Detected driver {DriverClass} with mixins {mixins}.") return combine_driver(DriverClass, *mixins) diff --git a/nonebot/dependencies/__init__.py b/nonebot/dependencies/__init__.py index 54853dee..147dcb1d 100644 --- a/nonebot/dependencies/__init__.py +++ b/nonebot/dependencies/__init__.py @@ -152,6 +152,12 @@ class Dependent(Generic[R]): ) ) + logger.trace( + f"Parsed dependent with call={call}, " + f"params={[param.field_info for param in dependent.params]}, " + f"parameterless={dependent.parameterless}" + ) + return dependent async def solve( diff --git a/nonebot/matcher.py b/nonebot/matcher.py index d33fed71..fa50f4c3 100644 --- a/nonebot/matcher.py +++ b/nonebot/matcher.py @@ -249,7 +249,6 @@ class Matcher(metaclass=MatcherMeta): - ``Type[Matcher]``: 新的事件响应器类 """ - NewMatcher = type( "Matcher", (Matcher,), @@ -282,6 +281,8 @@ class Matcher(metaclass=MatcherMeta): }, ) + logger.trace(f"Define new matcher {NewMatcher}") + matchers[priority].append(NewMatcher) return NewMatcher @@ -703,6 +704,10 @@ class Matcher(metaclass=MatcherMeta): stack: Optional[AsyncExitStack] = None, dependency_cache: Optional[T_DependencyCache] = None, ): + logger.trace( + f"Matcher {self} run with incoming args: " + f"bot={bot}, event={event}, state={state}" + ) b_t = current_bot.set(bot) e_t = current_event.set(event) m_t = current_matcher.set(self) diff --git a/poetry.lock b/poetry.lock index 7dc91309..e2611985 100644 --- a/poetry.lock +++ b/poetry.lock @@ -393,7 +393,7 @@ http2 = ["h2 (>=3,<5)"] [[package]] name = "hypercorn" -version = "0.13.1" +version = "0.13.2" description = "A ASGI Server based on Hyper libraries and inspired by Gunicorn" category = "main" optional = true @@ -555,7 +555,7 @@ pytest-asyncio = "^0.16.0" type = "git" url = "https://github.com/nonebot/nonebug.git" reference = "master" -resolved_reference = "6e2292f06b0b06dc2e1353ed1ef248a6c91fa2e4" +resolved_reference = "afc3c3fe2cf6300cdf1b5e1a897867a03a17e278" [[package]] name = "packaging" @@ -1636,8 +1636,8 @@ httpx = [ {file = "httpx-0.21.1.tar.gz", hash = "sha256:02af20df486b78892a614a7ccd4e4e86a5409ec4981ab0e422c579a887acad83"}, ] hypercorn = [ - {file = "Hypercorn-0.13.1-py3-none-any.whl", hash = "sha256:fcbfd5b691176cfcbf558cfa536909b2ef249af5528c99fcf941405c1c9aba74"}, - {file = "Hypercorn-0.13.1.tar.gz", hash = "sha256:3f55c7d0a51a93601d24fb773b88b1cd05c8ccb33e19294d1215bc0e19a6939c"}, + {file = "Hypercorn-0.13.2-py3-none-any.whl", hash = "sha256:ca18f91ab3fa823cbe9e949738f9f2cc07027cd647c80d8f93e4b1a2a175f112"}, + {file = "Hypercorn-0.13.2.tar.gz", hash = "sha256:6307be5cbdf6ba411967d4661202dc4f79bd511b5d318bc4eed88b09418427f8"}, ] hyperframe = [ {file = "hyperframe-6.0.1-py3-none-any.whl", hash = "sha256:0ec6bafd80d8ad2195c4f03aacba3a8265e57bc4cff261e802bf39970ed02a15"},