Skip to content

Commit bdf3230

Browse files
committed
expose loguru logger to plugins via astrbot.api
1 parent b3381c6 commit bdf3230

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

astrbot/api/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
from astrbot.core.agent.tool import FunctionTool, ToolSet
44
from astrbot.core.agent.tool_executor import BaseFunctionToolExecutor
55
from astrbot.core.config.astrbot_config import AstrBotConfig
6+
from astrbot.core.log import get_loguru_logger
67
from astrbot.core.star.register import register_agent as agent
78
from astrbot.core.star.register import register_llm_tool as llm_tool
89

10+
loguru_logger = get_loguru_logger()
11+
912
__all__ = [
1013
"AstrBotConfig",
1114
"BaseFunctionToolExecutor",
@@ -15,5 +18,6 @@
1518
"html_renderer",
1619
"llm_tool",
1720
"logger",
21+
"loguru_logger",
1822
"sp",
1923
]

astrbot/core/log.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,8 @@ def configure_trace_logger(cls, config: dict | None) -> None:
415415
backup_count=3,
416416
trace=True,
417417
)
418+
419+
420+
def get_loguru_logger():
421+
"""Returns the patched loguru logger for plugin use."""
422+
return _loguru

0 commit comments

Comments
 (0)