Skip to content

Commit 08da63a

Browse files
jsonbaileyclaude
andcommitted
chore: Use ldai.log instead of logging module in tracker
Replace logging.getLogger(__name__) with the SDK's shared log instance (from ldai import log) for consistency with the rest of the codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 31dcc8f commit 08da63a

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

packages/sdk/server-ai/src/ldai/tracker.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import base64
22
import json
3-
import logging
43
import time
54
from dataclasses import dataclass
65
from enum import Enum
76
from typing import Any, Callable, Dict, Iterable, List, Optional
87

98
from ldclient import Context, LDClient
109

11-
logger = logging.getLogger(__name__)
10+
from ldai import log
1211

1312

1413
class FeedbackKind(Enum):
@@ -201,7 +200,7 @@ def track_duration(self, duration: int) -> None:
201200
:param duration: Duration in milliseconds.
202201
"""
203202
if self._summary.duration is not None:
204-
logger.warning("Duration has already been tracked for this execution. %s", self.__get_track_data())
203+
log.warning("Duration has already been tracked for this execution. %s", self.__get_track_data())
205204
return
206205
self._summary._duration = duration
207206
self._ld_client.track(
@@ -215,7 +214,7 @@ def track_time_to_first_token(self, time_to_first_token: int) -> None:
215214
:param time_to_first_token: Time to first token in milliseconds.
216215
"""
217216
if self._summary.time_to_first_token is not None:
218-
logger.warning(
217+
log.warning(
219218
"Time to first token has already been tracked for this execution. %s",
220219
self.__get_track_data(),
221220
)
@@ -346,7 +345,7 @@ def track_feedback(self, feedback: Dict[str, FeedbackKind]) -> None:
346345
:param feedback: Dictionary containing feedback kind.
347346
"""
348347
if self._summary.feedback is not None:
349-
logger.warning("Feedback has already been tracked for this execution. %s", self.__get_track_data())
348+
log.warning("Feedback has already been tracked for this execution. %s", self.__get_track_data())
350349
return
351350
self._summary._feedback = feedback
352351
if feedback["kind"] == FeedbackKind.Positive:
@@ -369,7 +368,7 @@ def track_success(self) -> None:
369368
Track a successful AI generation.
370369
"""
371370
if self._summary.success is not None:
372-
logger.warning("Success has already been tracked for this execution. %s", self.__get_track_data())
371+
log.warning("Success has already been tracked for this execution. %s", self.__get_track_data())
373372
return
374373
self._summary._success = True
375374
self._ld_client.track(
@@ -381,7 +380,7 @@ def track_error(self) -> None:
381380
Track an unsuccessful AI generation attempt.
382381
"""
383382
if self._summary.success is not None:
384-
logger.warning("Success has already been tracked for this execution. %s", self.__get_track_data())
383+
log.warning("Success has already been tracked for this execution. %s", self.__get_track_data())
385384
return
386385
self._summary._success = False
387386
self._ld_client.track(
@@ -450,7 +449,7 @@ def track_tokens(self, tokens: TokenUsage) -> None:
450449
:param tokens: Token usage data from either custom, OpenAI, or Bedrock sources.
451450
"""
452451
if self._summary.usage is not None:
453-
logger.warning("Tokens have already been tracked for this execution. %s", self.__get_track_data())
452+
log.warning("Tokens have already been tracked for this execution. %s", self.__get_track_data())
454453
return
455454
self._summary._usage = tokens
456455
td = self.__get_track_data()

0 commit comments

Comments
 (0)