Skip to content

Commit bd78b2f

Browse files
committed
improve: latest log selector, use its own dir for logs, copy redacted logs to /sdcard/Download, use empty spaces for better readability
This commit makes DA select the most recent log file rather than number presence based; makes it create its own dir in /data/local/tmp/DebugAssistant (change the dir if you have detector OCD); copies the redacted logs to /sdcard/Download when you press the action button; improves some messages from action.sh; probably more I don't remember as I'm squashing this using fixup (:3) if you're reading this and you are Pedro: ily <3 Signed-off-by: TheSillyOk <priv.ld@proton.me>
1 parent 462c931 commit bd78b2f

2 files changed

Lines changed: 39 additions & 43 deletions

File tree

action.sh

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,30 @@
33
# A tool to redact sensitive information from the extremely verbose debug logs of Meow's Debug Assistant.
44
# LICENSE: BSD 3-Clause by ThePedroo
55

6-
echo "Selecting the latest debug log file..."
7-
8-
if [ -f "/data/local/tmp/DebugAssistant-Boot3.log" ]; then
9-
LATEST_DEBUG_LOG="/data/local/tmp/DebugAssistant-Boot3.log"
10-
elif [ -f "/data/local/tmp/DebugAssistant-Boot2.log" ]; then
11-
LATEST_DEBUG_LOG="/data/local/tmp/DebugAssistant-Boot2.log"
12-
elif [ -f "/data/local/tmp/DebugAssistant.log" ]; then
13-
LATEST_DEBUG_LOG="/data/local/tmp/DebugAssistant.log"
14-
else
15-
echo "No debug log found."
6+
log() {
7+
echo "$1"
8+
echo ""
9+
}
10+
11+
SAVE_FOLDER="/data/local/tmp/DebugAssistant"
12+
mkdir -p "$SAVE_FOLDER"
13+
14+
log "Selecting the latest debug log file..."
15+
16+
LATEST_SUFFIX=$(basename $(ls -t "$SAVE_FOLDER/"DebugAssistant* | grep -v "-Redacted" | head -n 1) | grep -oE "(-[0-9]+)?")
17+
LATEST="DebugAssistant$LATEST_SUFFIX.log"
18+
if [[ ! -f "$SAVE_FOLDER/$LATEST" ]]; then
19+
log "[!] No debug logs found. Exiting..."
20+
sleep 4
1621
exit 1
1722
fi
1823

19-
echo "Latest debug log selected: $LATEST_DEBUG_LOG"
24+
NEW_LOG="$SAVE_FOLDER/DebugAssistant-Redacted.log"
25+
DMESG_LOG="$SAVE_FOLDER/DebugAssistant-DMESG$LATEST_SUFFIX.log"
2026

21-
NEW_LOG="/data/local/tmp/DebugAssistant-Redacted.log"
22-
if [ -f "$NEW_LOG" ]; then
23-
rm "$NEW_LOG"
24-
fi
27+
log "Latest debug log selected: $LATEST"
2528

26-
echo "Redacting sensitive information..."
29+
log "Redacting sensitive information..."
2730

2831
sed -E \
2932
-e 's/([0-9]{1,3}\.){3}[0-9]{1,3}/XXX.XXX.XXX/g' \
@@ -58,6 +61,11 @@ sed -E \
5861
\
5962
\
6063
\
61-
"$LATEST_DEBUG_LOG" > "$NEW_LOG"
64+
"$SAVE_FOLDER/$LATEST" > "$NEW_LOG"
65+
66+
log "Redacted logs in $NEW_LOG"
6267

63-
echo "Redacted logs in $NEW_LOG"
68+
cp "$NEW_LOG" /sdcard/Download
69+
cp "$DMESG_LOG" /sdcard/Download
70+
log "Copied redacted log and matching dmesg to /sdcard/Download..."
71+
sleep 3

post-fs-data.sh

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,30 @@
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
6+
SAVE_FOLDER=/data/local/tmp/DebugAssistant
7+
8+
mkdir -p "$SAVE_FOLDER"
79

810
function prepare_file() {
9-
local file_path="$SAVE_FOLDER/DebugAssistant$1.log"
11+
local file_path="$1"
1012

13+
rm "$file_path"
1114
touch "$file_path"
1215
chown shell:shell "$file_path"
1316
}
1417

1518
function watch_logcat() {
1619
local file_path="$SAVE_FOLDER/DebugAssistant$1.log"
20+
prepare_file "$file_path"
1721

18-
logcat -f "$file_path" &
22+
while [ ! ];do logcat;sleep 1;done > "$file_path" &
1923
}
2024

21-
# Check if file exists
22-
if [ -f $SAVE_FOLDER/DebugAssistant.log ]; then
23-
# Check if file -2 exists
24-
if [ -f $SAVE_FOLDER/DebugAssistant-Boot2.log ]; then
25-
# Check if file -3 exists
26-
if [ -f $SAVE_FOLDER/DebugAssistant-Boot3.log ]; then
27-
rm $SAVE_FOLDER/DebugAssistant-Boot3.log
28-
rm $SAVE_FOLDER/DebugAssistant-Boot2.log
29-
rm $SAVE_FOLDER/DebugAssistant.log
30-
31-
prepare_file ""
32-
watch_logcat ""
33-
else
34-
prepare_file "-Boot3"
35-
watch_logcat "-Boot3"
36-
fi
37-
else
38-
prepare_file "-Boot2"
39-
watch_logcat "-Boot2"
40-
fi
25+
LATEST_SUFFIX=$(basename $(ls -t "$SAVE_FOLDER"/DebugAssistant*.log | grep -v "Redacted" | head -n 1) | grep -oE "([0-9]+)?")
26+
if [[ -z "$(ls $SAVE_FOLDER/DebugAssistant*.log)" || "${LATEST_SUFFIX:-1}" -ge 3 ]]; then
27+
SUFFIX=""
4128
else
42-
prepare_file ""
43-
watch_logcat ""
29+
SUFFIX="-$(( ${LATEST_SUFFIX:-1} + 1 ))"
4430
fi
31+
32+
watch_logcat "$SUFFIX"

0 commit comments

Comments
 (0)