File tree Expand file tree Collapse file tree 3 files changed +33
-12
lines changed
kagent-adk/src/kagent/adk
kagent-core/src/kagent/core Expand file tree Collapse file tree 3 files changed +33
-12
lines changed Original file line number Diff line number Diff line change 99from a2a .types import AgentCard
1010from google .adk .cli .utils .agent_loader import AgentLoader
1111
12- from kagent .core import KAgentConfig , configure_tracing
12+ from kagent .core import KAgentConfig , configure_logging , configure_tracing
1313
1414from . import AgentConfig , KAgentApp
1515from .skill_fetcher import fetch_skill
@@ -134,16 +134,6 @@ def test(
134134 asyncio .run (test_agent (agent_config , agent_card , task ))
135135
136136
137- # --- Configure Logging ---
138- def configure_logging () -> None :
139- """Configure logging based on LOG_LEVEL environment variable."""
140- log_level = os .getenv ("LOG_LEVEL" , "INFO" ).upper ()
141- logging .basicConfig (
142- level = log_level ,
143- )
144- logging .info (f"Logging configured with level: { log_level } " )
145-
146-
147137def run_cli ():
148138 configure_logging ()
149139 logger .info ("Starting KAgent" )
Original file line number Diff line number Diff line change 11from ._config import KAgentConfig
2+ from ._logging import configure_logging
23from .tracing import configure as configure_tracing
34
4- __all__ = ["KAgentConfig" , "configure_tracing" ]
5+ configure_logging ()
6+
7+ __all__ = ["KAgentConfig" , "configure_tracing" , "configure_logging" ]
Original file line number Diff line number Diff line change 1+ import logging
2+ import os
3+
4+ _logging_configured = False
5+
6+
7+ def configure_logging () -> None :
8+ """Configure logging based on LOG_LEVEL environment variable."""
9+ global _logging_configured
10+
11+ log_level = os .getenv ("LOG_LEVEL" , "INFO" ).upper ()
12+
13+ # Only configure if not already configured (avoid duplicate handlers)
14+ if not logging .root .handlers :
15+ logging .basicConfig (
16+ level = log_level ,
17+ format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ,
18+ )
19+ _logging_configured = True
20+ logging .info (f"Logging configured with level: { log_level } " )
21+ elif not _logging_configured :
22+ # Update level if already configured but we haven't logged yet
23+ logging .root .setLevel (log_level )
24+ _logging_configured = True
25+ logging .info (f"Logging level updated to: { log_level } " )
26+ else :
27+ # Already configured and logged, just update the level silently
28+ logging .root .setLevel (log_level )
You can’t perform that action at this time.
0 commit comments