Skip to content

Commit c5434c1

Browse files
committed
[refactor] Simplify container log output formatting and logging
1 parent d350fc5 commit c5434c1

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

python/fedml/computing/scheduler/model_scheduler/device_model_deployment.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,12 @@ def log_deployment_output(end_point_id, model_id, cmd_container_name, cmd_type,
360360
if err_logs is not None:
361361
err_logs = sys_utils.decode_our_err_result(err_logs)
362362
if len(err_logs) > 0:
363-
logging.info("[-- Container Error Logs Start --]")
364-
logging.error(f"{format(err_logs)}")
365-
logging.info("[-- Container Error Logs End --]")
363+
logging.error(f"[-- Container Error Logs Start --]\n{format(err_logs)}\n[-- Container Error Logs End --]")
366364

367365
if out_logs is not None:
368366
out_logs = sys_utils.decode_our_err_result(out_logs)
369367
if len(out_logs) > 0:
370-
logging.info("[-- Container Stdout Logs Start --]")
371-
logging.info(f"{format(out_logs)}")
372-
logging.info("[-- Container Stdout Logs End --]")
368+
logging.info(f"[-- Container Stdout Logs Start --]\n{format(out_logs)}\n[-- Container Stdout Logs End --]")
373369

374370
if container_obj.status == "exited":
375371
logging.info("Container {} has exited, automatically remove it".format(cmd_container_name))
@@ -383,7 +379,7 @@ def log_deployment_output(end_point_id, model_id, cmd_container_name, cmd_type,
383379
raw_logs = f.readlines()
384380
out_logs = '\n'.join([line for line in raw_logs if '"stream":"stdout"' in line])
385381
err_logs = '\n'.join([line for line in raw_logs if '"stream":"stderr"' in line])
386-
logging.info(f"read Container Error Logs from log file: {err_logs}")
382+
logging.error(f"read Container Error Logs from log file: {err_logs}")
387383
except Exception as e:
388384
logging.warning(f"Failed to read logs from filesystem: {str(e)}")
389385

0 commit comments

Comments
 (0)