-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(android): add android:logs command (#2050)
Call `yarn android:logs` to see all `adb logcat` output from the example app running on android. If the process isn’t started yet, it will wait for it. If the process is restarted, logging will also restart.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME=com.example | ||
|
||
function monitor_logs { | ||
echo "Monitoring logs for PID: $1" | ||
adb logcat --pid="$1" & | ||
LOGCAT_PID=$! | ||
|
||
while adb shell "pidof -s $PACKAGE_NAME >/dev/null"; do | ||
sleep 1 | ||
done | ||
|
||
echo "Process $1 stopped. Killing logcat process..." | ||
kill $LOGCAT_PID | ||
} | ||
|
||
while true; do | ||
PID=$(adb shell pidof -s $PACKAGE_NAME) | ||
|
||
if [ -n "$PID" ]; then | ||
monitor_logs "$PID" | ||
else | ||
echo "$PACKAGE_NAME is not running. Waiting for process..." | ||
sleep 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters