Skip to content

Commit 0cde3d9

Browse files
authored
chore: require valid logging category (#3712)
# What does this PR do? grep'd and audited all usage of 'get_logger' with help of Claude. ## Test Plan CI
1 parent a3f5072 commit 0cde3d9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

llama_stack/core/conversations/conversations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
sqlstore_impl,
3333
)
3434

35-
logger = get_logger(name=__name__, category="openai::conversations")
35+
logger = get_logger(name=__name__, category="openai_conversations")
3636

3737

3838
class ConversationServiceConfig(BaseModel):

llama_stack/log.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@
3131
"client",
3232
"telemetry",
3333
"openai_responses",
34+
"openai_conversations",
3435
"testing",
3536
"providers",
3637
"models",
3738
"files",
3839
"vector_io",
3940
"tool_runtime",
41+
"cli",
42+
"post_training",
43+
"scoring",
44+
"tests",
4045
]
4146
UNCATEGORIZED = "uncategorized"
4247

@@ -261,11 +266,12 @@ def get_logger(
261266
if root_category in _category_levels:
262267
log_level = _category_levels[root_category]
263268
else:
264-
log_level = _category_levels.get("root", DEFAULT_LOG_LEVEL)
265269
if category != UNCATEGORIZED:
266-
logging.warning(
267-
f"Unknown logging category: {category}. Falling back to default 'root' level: {log_level}"
270+
raise ValueError(
271+
f"Unknown logging category: {category}. To resolve, choose a valid category from the CATEGORIES list "
272+
f"or add it to the CATEGORIES list. Available categories: {CATEGORIES}"
268273
)
274+
log_level = _category_levels.get("root", DEFAULT_LOG_LEVEL)
269275
logger.setLevel(log_level)
270276
return logging.LoggerAdapter(logger, {"category": category})
271277

0 commit comments

Comments
 (0)