Skip to content

Commit

Permalink
[Core] Fix structured logging to use explicit value (ray-project#46523)
Browse files Browse the repository at this point in the history
Signed-off-by: hongchaodeng <[email protected]>
  • Loading branch information
hongchaodeng committed Jul 10, 2024
1 parent a6c3da3 commit f466cad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions python/ray/_private/ray_logging/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def filter(self, record):
return True

runtime_context = ray.get_runtime_context()
setattr(record, LogKey.JOB_ID, runtime_context.get_job_id())
setattr(record, LogKey.WORKER_ID, runtime_context.get_worker_id())
setattr(record, LogKey.NODE_ID, runtime_context.get_node_id())
setattr(record, LogKey.JOB_ID.value, runtime_context.get_job_id())
setattr(record, LogKey.WORKER_ID.value, runtime_context.get_worker_id())
setattr(record, LogKey.NODE_ID.value, runtime_context.get_node_id())
if runtime_context.worker.mode == ray.WORKER_MODE:
actor_id = runtime_context.get_actor_id()
if actor_id is not None:
Expand Down
12 changes: 6 additions & 6 deletions python/ray/_private/ray_logging/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ def generate_record_format_attrs(
# Otherwise, include only Ray and user-provided context.
if not exclude_standard_attrs:
record_format_attrs = {
LogKey.ASCTIME: formatter.formatTime(record),
LogKey.LEVELNAME: record.levelname,
LogKey.MESSAGE: record.getMessage(),
LogKey.FILENAME: record.filename,
LogKey.LINENO: record.lineno,
LogKey.ASCTIME.value: formatter.formatTime(record),
LogKey.LEVELNAME.value: record.levelname,
LogKey.MESSAGE.value: record.getMessage(),
LogKey.FILENAME.value: record.filename,
LogKey.LINENO.value: record.lineno,
}
if record.exc_info:
if not record.exc_text:
record.exc_text = formatter.formatException(record.exc_info)
record_format_attrs[LogKey.EXC_TEXT] = record.exc_text
record_format_attrs[LogKey.EXC_TEXT.value] = record.exc_text

for key, value in record.__dict__.items():
# Both Ray and user-provided context are stored in `record_format`.
Expand Down

0 comments on commit f466cad

Please sign in to comment.