Files
clientCommands/scripts/logs.sh
T
exteraGramPlugins 787965ebbf Initial commit
2026-10-09 12:25:06 +00:00

40 lines
791 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$ADB"
CLEAR=0
STDIO=0
PATTERN=""
while [[ $# -gt 0 ]]; do
case "$1" in
-c) CLEAR=1; shift ;;
-t) STDIO=1; shift ;;
-g) PATTERN="${2:-}"; shift 2 ;;
*) die "unknown argument: $1" ;;
esac
done
if [[ "$CLEAR" -eq 1 ]]; then
"$ADB" logcat -c
fi
run_logcat() {
if [[ "$STDIO" -eq 1 ]]; then
"$ADB" logcat -s python.stdout:'*' python.stderr:'*'
else
local pid
pid="$(app_pid)"
[[ -n "$pid" ]] || die "exteraGram is not running — open the app first"
"$ADB" logcat --pid="$pid"
fi
}
if [[ -n "$PATTERN" ]]; then
run_logcat | grep --line-buffered -E "$PATTERN"
else
run_logcat
fi