diff options
| author | 2024-06-08 00:53:08 +0000 | |
|---|---|---|
| committer | 2024-06-08 00:53:08 +0000 | |
| commit | df1ba7c5ff16152ee1f35cb846664ac669a601bc (patch) | |
| tree | 8244ee8ef376ed3941a0f93c974eb091f6f1ebac | |
| parent | 878141b810c6c2e773c34dc5d9132d6893e36b95 (diff) | |
| parent | 1f6eddbc359973816a46488e263e9efd00f1fedd (diff) | |
Merge "Move the impl of run_tool_with_logging into shell_utils.sh" into main
| -rw-r--r-- | shell_utils.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/shell_utils.sh b/shell_utils.sh index 450bb836a6..86f3f49f50 100644 --- a/shell_utils.sh +++ b/shell_utils.sh @@ -126,4 +126,27 @@ function _wrap_build() } +function log_tool_invocation() +{ + if [[ -z $ANDROID_TOOL_LOGGER ]]; then + return + fi + + LOG_TOOL_TAG=$1 + LOG_START_TIME=$(date +%s.%N) + trap ' + exit_code=$?; + # Remove the trap to prevent duplicate log. + trap - EXIT; + $ANDROID_TOOL_LOGGER \ + --tool_tag="${LOG_TOOL_TAG}" \ + --start_timestamp="${LOG_START_TIME}" \ + --end_timestamp="$(date +%s.%N)" \ + --tool_args="$*" \ + --exit_code="${exit_code}" \ + ${ANDROID_TOOL_LOGGER_EXTRA_ARGS} \ + > /dev/null 2>&1 & + exit ${exit_code} + ' SIGINT SIGTERM SIGQUIT EXIT +} |