Adding exit code to log messages
@@ -47,20 +47,20 @@ def run_command(hutil, args, cwd, operation, extension_short_name, version, exit
stderr=err_out)
time.sleep(1)
while child.poll() is None:
- msg_with_cmd_output = LogUtil.get_formatted_log("Command is running...",
- LogUtil.tail(std_out_file), LogUtil.tail(err_out_file))
- msg_without_cmd_output = "Command is running... Stdout/Stderr omitted from output."
+ msg = "Command is running... "
+ msg_with_cmd_output = LogUtil.get_formatted_log(msg, LogUtil.tail(std_out_file), LogUtil.tail(err_out_file))
+ msg_without_cmd_output = msg + "Stdout/Stderr omitted from output."
+
hutil.log_to_file(msg_with_cmd_output)
hutil.log_to_console(msg_without_cmd_output)
-
hutil.do_status_report(operation, 'transitioning', '0', msg_without_cmd_output)
time.sleep(interval)
exit_code = child.returncode
if child.returncode and child.returncode != 0:
- msg_with_cmd_output = LogUtil.get_formatted_log("Command returned an error.",
- LogUtil.tail(std_out_file), LogUtil.tail(err_out_file))
- msg_without_cmd_output = "Command returned an error. Stdout/Stderr omitted from output."
+ msg = "Command returned an error (exit_code: %d). " % exit_code
+ msg_with_cmd_output = LogUtil.get_formatted_log(msg, LogUtil.tail(std_out_file), LogUtil.tail(err_out_file))
+ msg_without_cmd_output = msg + "Stdout/Stderr omitted from output."
hutil.error(msg_without_cmd_output)
waagent.AddExtensionEvent(name=extension_short_name,
@@ -69,12 +69,12 @@ def run_command(hutil, args, cwd, operation, extension_short_name, version, exit
version=version,
message="(01302)" + msg_without_cmd_output)
else:
- msg_with_cmd_output = LogUtil.get_formatted_log("Command is finished.",
- LogUtil.tail(std_out_file), LogUtil.tail(err_out_file))
- msg_without_cmd_output = "Command is finished. Stdout/Stderr omitted from output."
+ msg = "Command is finished (exit_code: %d). " % exit_code
+ msg_with_cmd_output = LogUtil.get_formatted_log(msg, LogUtil.tail(std_out_file), LogUtil.tail(err_out_file))
+ msg_without_cmd_output = msg + "Stdout/Stderr omitted from output."
+
hutil.log_to_file(msg_with_cmd_output)
hutil.log_to_console(msg_without_cmd_output)
-
waagent.AddExtensionEvent(name=extension_short_name,
op=operation,
isSuccess=True,
