Skip to content

Commit 21c7679

Browse files
committed
add: dmesg logging; improve: make logs based on extracted suffix for dmesg pairing with logcats on action.sh
This commit uses grep -oE to extract the log suffix "-2" (action.sh) or "2" (post-fs-data.sh) it allows the new dmesg logs to be paired with the corresponding log on the action script and also allow a simplification on post-fs-data.sh by checking if the last log is not the last before returning to the starting log (3) and if the initial log is existent to add 1 to the last log which defaults to 2 (1+1) if it doesn't contain a suffix (first log) while if the starting log is non existent or the last log was the finishing one before looping back (3) it will use no suffix to create the starting log Signed-off-by: TheSillyOk <priv.ld@proton.me>
1 parent bd78b2f commit 21c7679

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

post-fs-data.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,47 @@
33
# A tool to collect extremely verbose debug log from the Android system.
44
# LICENSE: BSD 3-Clause by ThePedroo
55

6-
SAVE_FOLDER=/data/local/tmp/DebugAssistant
7-
6+
SAVE_FOLDER="/data/local/tmp/DebugAssistant"
87
mkdir -p "$SAVE_FOLDER"
98

10-
function prepare_file() {
9+
start_log() {
10+
local suffix="$1"
11+
12+
watch_logcat "$suffix"
13+
watch_dmesg "$suffix"
14+
}
15+
16+
prepare_file() {
1117
local file_path="$1"
1218

1319
rm "$file_path"
1420
touch "$file_path"
1521
chown shell:shell "$file_path"
1622
}
1723

18-
function watch_logcat() {
24+
watch_logcat() {
1925
local file_path="$SAVE_FOLDER/DebugAssistant$1.log"
2026
prepare_file "$file_path"
2127

2228
while [ ! ];do logcat;sleep 1;done > "$file_path" &
2329
}
2430

31+
watch_dmesg() {
32+
local file_path="$SAVE_FOLDER/DebugAssistant-DMESG$1.log"
33+
prepare_file "$file_path"
34+
35+
if dmesg --help 2>&1 | grep -q "\-w"; then
36+
dmesg -w > "$file_path" &
37+
else
38+
while [ ! ];do dmesg > "$file_path";sleep 1;done &
39+
fi
40+
}
41+
2542
LATEST_SUFFIX=$(basename $(ls -t "$SAVE_FOLDER"/DebugAssistant*.log | grep -v "Redacted" | head -n 1) | grep -oE "([0-9]+)?")
2643
if [[ -z "$(ls $SAVE_FOLDER/DebugAssistant*.log)" || "${LATEST_SUFFIX:-1}" -ge 3 ]]; then
2744
SUFFIX=""
2845
else
2946
SUFFIX="-$(( ${LATEST_SUFFIX:-1} + 1 ))"
3047
fi
3148

32-
watch_logcat "$SUFFIX"
49+
start_log "$SUFFIX"

0 commit comments

Comments
 (0)