File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,21 @@ def _is_plugin_path(pathname: str | None) -> bool:
5959 return ("data/plugins" in norm_path ) or ("astrbot/builtin_stars/" in norm_path )
6060
6161
62+ def _get_plugin_tag (pathname : str | None ) -> str :
63+ if not pathname :
64+ return "[Core]"
65+ norm_path = os .path .normpath (pathname )
66+ for prefix in (
67+ "data" + os .sep + "plugins" + os .sep ,
68+ "astrbot" + os .sep + "builtin_stars" + os .sep ,
69+ ):
70+ if prefix in norm_path :
71+ idx = norm_path .index (prefix ) + len (prefix )
72+ plugin_name = norm_path [idx :].split (os .sep )[0 ]
73+ return f"[{ plugin_name } ]"
74+ return "[Core]"
75+
76+
6277def _get_short_level_name (level_name : str ) -> str :
6378 level_map = {
6479 "DEBUG" : "DBUG" ,
@@ -81,7 +96,7 @@ def _build_source_file(pathname: str | None) -> str:
8196
8297def _patch_record (record : "Record" ) -> None :
8398 extra = record ["extra" ]
84- extra .setdefault ("plugin_tag" , "[Core]" )
99+ extra .setdefault ("plugin_tag" , _get_plugin_tag ( record [ "file" ]. path ) )
85100 extra .setdefault ("short_levelname" , _get_short_level_name (record ["level" ].name ))
86101 level_no = record ["level" ].no
87102 extra .setdefault ("astrbot_version_tag" , f" [v{ VERSION } ]" if level_no >= 30 else "" )
You can’t perform that action at this time.
0 commit comments