[Housekeeping] Improved logging for all executable calls (#244)

* Improved logging for all CLI calls

* CAptured more details in logging
This commit is contained in:
Kieran
2024-05-15 12:56:56 -07:00
committed by GitHub
parent bdcb49185a
commit 8d9bd11882
7 changed files with 24 additions and 15 deletions
+11 -1
View File
@@ -28,7 +28,10 @@ defmodule Pinchflat.Utils.CliUtils do
Logger.info("[command_wrapper]: #{command} called with: #{logging_arg_override}")
System.cmd(wrapper_command, actual_command, passthrough_opts)
{output, status} = System.cmd(wrapper_command, actual_command, passthrough_opts)
log_cmd_result(command, logging_arg_override, status, output)
{output, status}
end
@doc """
@@ -71,4 +74,11 @@ defmodule Pinchflat.Utils.CliUtils do
defp parse_option(arg, acc) when is_binary(arg) do
acc ++ [arg]
end
defp log_cmd_result(command, logging_arg_override, status, output) do
log_message = "[command_wrapper]: #{command} called with: #{logging_arg_override} exited: #{status} with: #{output}"
log_level = if status == 0, do: :debug, else: :error
Logger.log(log_level, log_message)
end
end