Skip to content

Commit 6e8a5a8

Browse files
committed
chore: improve logging
1 parent 2c2894a commit 6e8a5a8

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ LABEL maintainer="Lawrence McDaniel <lpm0073@gmail.com>" \
99
org.opencontainers.image.title="StackademyAssistent" \
1010
org.opencontainers.image.version="0.1.0" \
1111
org.opencontainers.image.authors="Lawrence McDaniel <lpm0073@gmail.com>" \
12-
org.opencontainers.image.url="https://FullStackWithLawrence.github.io/smarter/" \
12+
org.opencontainers.image.url="https://FullStackWithLawrence.github.io/agentic-ai-workflow/" \
1313
org.opencontainers.image.source="https://github.com/FullStackWithLawrence/agentic-ai-workflow" \
14-
org.opencontainers.image.documentation="https://FullStackWithLawrence.github.io/smarter/"
14+
org.opencontainers.image.documentation="https://FullStackWithLawrence.github.io/agentic-ai-workflow/"
1515

1616

1717
FROM base AS requirements

app/database.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def __init__(self):
4141
"MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE"
4242
)
4343

44+
@property
45+
def connection_string(self) -> str:
46+
"""Return the database connection string."""
47+
return f"{self.user}@{self.host}:{self.port}/{self.database}"
48+
4449
def get_connection(self) -> pymysql.Connection:
4550
"""
4651
Create and return a new MySQL connection.

app/logging_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def setup_logging(level: int = LOGGING_LEVEL) -> logging.Logger:
2727
handlers=[logging.StreamHandler(sys.stdout)], # This logs to console
2828
)
2929

30+
logging.getLogger("httpx").setLevel(logging.WARNING)
31+
3032
return logging.getLogger(__name__)
3133

3234

app/stackademy.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def _log_success(self, message: str) -> None:
6767
def tool_factory_get_courses(self) -> ChatCompletionFunctionToolParam:
6868
"""LLM Factory function to create a tool for getting courses"""
6969
schema = StackademyGetCoursesParams.model_json_schema()
70-
schema["required"] = [] # Both parameters are optional
7170
return ChatCompletionFunctionToolParam(
7271
type="function",
7372
function={
@@ -80,7 +79,6 @@ def tool_factory_get_courses(self) -> ChatCompletionFunctionToolParam:
8079
def tool_factory_register(self) -> ChatCompletionFunctionToolParam:
8180
"""LLMFactory function to create a tool for registering a user"""
8281
schema = StackademyRegisterCourseParams.model_json_schema()
83-
schema["required"] = ["course_code", "email", "full_name"] # All parameters are required
8482
return ChatCompletionFunctionToolParam(
8583
type="function",
8684
function={
@@ -115,7 +113,7 @@ def get_courses(self, description: Optional[str] = None, max_cost: Optional[floa
115113
Returns:
116114
List[Dict[str, Any]]: List of courses matching the criteria
117115
"""
118-
# Base query
116+
119117
query = """
120118
SELECT
121119
c.course_code,
@@ -128,7 +126,6 @@ def get_courses(self, description: Optional[str] = None, max_cost: Optional[floa
128126
LEFT JOIN courses prerequisite ON c.prerequisite_id = prerequisite.course_id
129127
"""
130128

131-
# Build WHERE clause dynamically
132129
where_conditions = []
133130
params = []
134131

@@ -140,14 +137,15 @@ def get_courses(self, description: Optional[str] = None, max_cost: Optional[floa
140137
where_conditions.append("c.cost <= %s")
141138
params.append(max_cost)
142139

143-
# Add WHERE clause if we have conditions
144140
if where_conditions:
145141
query += " WHERE " + " AND ".join(where_conditions)
146142

147143
query += " ORDER BY c.prerequisite_id"
148-
logger.info("get_courses() executing db query with params: %s", params)
144+
149145
try:
150-
return self.db.execute_query(query, tuple(params))
146+
retval = self.db.execute_query(query, tuple(params))
147+
logger.info("get_courses() retrieved %d rows from %s", len(retval), self.db.connection_string)
148+
return retval
151149
# pylint: disable=broad-except
152150
except Exception as e:
153151
logger.error("Failed to retrieve courses: %s", e)
@@ -190,9 +188,9 @@ def register_course(self, course_code: str, email: str, full_name: str) -> bool:
190188
if MISSING in (course_code, email, full_name):
191189
raise ConfigurationException("Missing required registration parameters.")
192190

193-
full_name = full_name.title().strip()
194-
email = email.lower().strip()
195-
course_code = course_code.upper().strip()
191+
full_name = full_name.title().strip() if isinstance(full_name, str) else full_name
192+
email = email.lower().strip() if isinstance(email, str) else email
193+
course_code = course_code.upper().strip() if isinstance(course_code, str) else course_code
196194

197195
logger.info("Registering %s (%s) for course %s...", full_name, email, course_code)
198196
if not self.verify_course(course_code):

run.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)