Skip to content

Commit

Permalink
fix: make SetMetadata add extra labels rather than replace the logger (
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 authored Sep 26, 2024
1 parent c4790e3 commit 4714c29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/isolate/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# but it handling `source` would be not trivial, so we are better off
# just keeping it simple for now.
class IsolateLogger:
extra_labels: Dict[str, str] = {}

def __init__(self, log_labels: Dict[str, str]):
self.log_labels = log_labels

Expand All @@ -18,6 +20,7 @@ def log(self, level: LogLevel, message: str, source: LogSource) -> None:
"level": level.name,
"message": message,
**self.log_labels,
**self.extra_labels,
}
print(json.dumps(record))

Expand Down
4 changes: 1 addition & 3 deletions src/isolate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,7 @@ def SetMetadata(

task = self.background_tasks[request.task_id]

task.logger = IsolateLogger.with_env_expanded(
dict(request.metadata.logger_labels)
)
task.logger.extra_labels = dict(request.metadata.logger_labels)

return definitions.SetMetadataResponse()

Expand Down

0 comments on commit 4714c29

Please sign in to comment.