Skip to content

Commit dd8cd27

Browse files
GWealecopybara-github
authored andcommitted
chore: Replace print statements with logging in ADK
Co-authored-by: George Weale <[email protected]> PiperOrigin-RevId: 864588921
1 parent e87a843 commit dd8cd27

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/google/adk/a2a/utils/agent_card_builder.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from __future__ import annotations
1616

17+
import logging
1718
import re
1819
from typing import Dict
1920
from typing import List
@@ -33,6 +34,8 @@
3334
from ...tools.example_tool import ExampleTool
3435
from ..experimental import a2a_experimental
3536

37+
logger = logging.getLogger('google_adk.' + __name__)
38+
3639

3740
@a2a_experimental
3841
class AgentCardBuilder:
@@ -157,8 +160,8 @@ async def _build_sub_agent_skills(agent: BaseAgent) -> List[AgentSkill]:
157160
sub_agent_skills.append(aggregated_skill)
158161
except Exception as e:
159162
# Log warning but continue with other sub-agents
160-
print(
161-
f'Warning: Failed to build skills for sub-agent {sub_agent.name}: {e}'
163+
logger.warning(
164+
'Failed to build skills for sub-agent %s: %s', sub_agent.name, e
162165
)
163166
continue
164167

@@ -502,7 +505,7 @@ async def _extract_examples_from_agent(
502505
if isinstance(tool, ExampleTool):
503506
return _convert_example_tool_examples(tool)
504507
except Exception as e:
505-
print(f'Warning: Failed to extract examples from tools: {e}')
508+
logger.warning('Failed to extract examples from tools: %s', e)
506509

507510
# If no example_tool found, try to extract examples from instruction
508511
if agent.instruction:

src/google/adk/evaluation/evaluation_generator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import copy
1818
import importlib
19+
import logging
1920
from typing import Any
2021
from typing import AsyncGenerator
2122
from typing import Optional
@@ -49,6 +50,8 @@
4950
from .simulation.user_simulator import UserSimulator
5051
from .simulation.user_simulator_provider import UserSimulatorProvider
5152

53+
logger = logging.getLogger("google_adk." + __name__)
54+
5255
_USER_AUTHOR = "user"
5356
_DEFAULT_AUTHOR = "agent"
5457

@@ -117,7 +120,7 @@ def generate_responses_from_session(session_path, eval_dataset):
117120

118121
with open(session_path, "r") as f:
119122
session_data = Session.model_validate_json(f.read())
120-
print("loaded session", session_path)
123+
logger.info("Loaded session %s", session_path)
121124

122125
for data in eval_dataset:
123126
# load session data from session_path

src/google/adk/tools/bigtable/query_tool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
"""Tool to execute SQL queries against Bigtable."""
1818
import json
19+
import logging
1920
from typing import Any
2021
from typing import Dict
2122
from typing import List
@@ -27,6 +28,8 @@
2728
from ..tool_context import ToolContext
2829
from .settings import BigtableToolSettings
2930

31+
logger = logging.getLogger("google_adk." + __name__)
32+
3033
DEFAULT_MAX_EXECUTED_QUERY_RESULT_ROWS = 50
3134

3235

@@ -112,7 +115,7 @@ def execute_sql(
112115
return result
113116

114117
except Exception as ex:
115-
print(ex)
118+
logger.error("Bigtable query failed: %s", ex)
116119
return {
117120
"status": "ERROR",
118121
"error_details": str(ex),

0 commit comments

Comments
 (0)