platform_system_core/logcat/logcatd
Tom Cherry 98c6c3304a logcat: fix logcatd / logpersist
Removing the rest of liblogcat broke logcatd since LogcatPanic() now
actually calls exit(), whereas logcatd relied on it to return
normally.

We can achieve the expected behavior with a small shell script, so
this change does that as well.

Test: logcatd / logpersist work
Change-Id: Icde36a4811a0db987a801978485e1af1dfc3d38c
2019-10-31 06:43:47 -07:00

25 lines
598 B
Bash
Executable file

#! /system/bin/sh
# This is primarily meant to be used by logpersist. This script is run as an init service, which
# first reads the 'last' logcat to persistent storage with `-L` then run logcat again without
# `-L` to read the current logcat buffers to persistent storage.
has_last="false"
for arg in "$@"; do
if [ "$arg" == "-L" -o "$arg" == "--last" ]; then
has_last="true"
fi
done
if [ "$has_last" == "true" ]; then
logcat "$@"
fi
args_without_last=()
for arg in "$@"; do
if [ "$arg" != "-L" -a "$arg" != "--last" ]; then
ARGS+=("$arg")
fi
done
exec logcat "${ARGS[@]}"