summaryrefslogtreecommitdiff
path: root/envsetup.sh
diff options
context:
space:
mode:
author Zhuoyao Zhang <zhuoyao@google.com> 2024-05-21 23:55:27 +0000
committer Zhuoyao Zhang <zhuoyao@google.com> 2024-06-06 23:53:36 +0000
commit1698d49b55d49f1a1169fbf586b1d929782f4308 (patch)
tree9c6f56172eb39b406ef5532f16b50b31283b9d77 /envsetup.sh
parentb20aee1b1e015171986afa5c2ddfcd3452d3b2dc (diff)
Remove run_tool_with_logging function from envsetup.sh
As part of the build team's effort to cleanup envseup.sh. Remove the run_tool_with_logging rundtion from envsetup.sh and add it as a standalone script under build/soong/bin Test: atest run_tool_with_logging Test: manually do source envsetup.sh and run adb devices -l and check the event log is sent to clearcut, tested with both bash and zsh Bug: 342066042 Change-Id: I9c23a1b0a4b5790fb32f5e84fd7421ee6b36bdb0
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh44
1 files changed, 1 insertions, 43 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 352d66442f..0ccb63172c 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -865,49 +865,6 @@ function adb() {
run_tool_with_logging "ADB" $ADB "${@}"
}
-function run_tool_with_logging() {
- # Run commands in a subshell for us to handle forced terminations with a trap
- # handler.
- (
- local tool_tag="$1"
- shift
- local tool_binary="$1"
- shift
-
- # If the logger is not configured, run the original command and return.
- if [[ -z "${ANDROID_TOOL_LOGGER}" ]]; then
- "${tool_binary}" "${@}"
- return $?
- fi
-
- # Otherwise, run the original command and call the logger when done.
- local start_time
- start_time=$(date +%s.%N)
- local logger=${ANDROID_TOOL_LOGGER}
-
- # Install a trap to call the logger even when the process terminates abnormally.
- # The logger is run in the background and its output suppressed to avoid
- # interference with the user flow.
- trap '
- exit_code=$?;
- # Remove the trap to prevent duplicate log.
- trap - EXIT;
- "${logger}" \
- --tool_tag="${tool_tag}" \
- --start_timestamp="${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
-
- # Run the original command.
- "${tool_binary}" "${@}"
- )
-}
-
# communicate with a running device or emulator, set up necessary state,
# and run the hat command.
function runhat()
@@ -1195,6 +1152,7 @@ unset rcgrep
unset refreshmod
unset resgrep
unset rsgrep
+unset run_tool_with_logging
unset sepgrep
unset sgrep
unset startviewserver