59 lines
2.2 KiB
Bash
Executable File
59 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
FILTER="$1"
|
|
|
|
if [[ -z "$FILTER" ]]; then
|
|
echo "Usage: $(basename "$0") <bundle-id-prefix|process-name>"
|
|
echo ""
|
|
echo " Examples:"
|
|
echo " $(basename "$0") com.mycompany.myapp"
|
|
echo " $(basename "$0") MyApp"
|
|
exit 1
|
|
fi
|
|
|
|
RED=$'\033[0;31m'
|
|
YELLOW=$'\033[0;33m'
|
|
CYAN=$'\033[0;36m'
|
|
GREEN=$'\033[0;32m'
|
|
DIM=$'\033[2m'
|
|
RESET=$'\033[0m'
|
|
|
|
SEP="${DIM}────────────────────────────────────────${RESET}"
|
|
|
|
cleanup() {
|
|
printf "\n%s[applog] Stopped.%s\n" "$DIM" "$RESET"
|
|
exit 0
|
|
}
|
|
|
|
trap cleanup SIGINT SIGTERM
|
|
|
|
printf "%s[applog] Filtering for '%s'. Ctrl+C to stop.%s\n\n" "$DIM" "$FILTER" "$RESET"
|
|
|
|
# System daemons that reference app bundle IDs as incidental observers, not direct participants
|
|
BLOCKLIST_RE='^(runningboardd|lsd|trustd|aggregated|tccd|dasd|symptomsd|swcd|calaccessd|mobileassetd|fairplayd|statusbarserver|contextstore|assertiond|thermalmonitord|watchdogd|powerd|logd|notifyd|configd|launchd|mDNSResponder)$'
|
|
|
|
idevicesyslog 2>/dev/null | while IFS= read -r line; do
|
|
[[ "$line" != *"$FILTER"* ]] && continue
|
|
|
|
# Extract process name (stop at '(' or '[' — handles both "proc[sub][pid]" and "proc(sub)[pid]")
|
|
# idevicesyslog format: "Mon DD HH:MM:SS.ssssss processname(subsystem)[pid] <Level>: msg"
|
|
if [[ "$line" =~ ^[A-Za-z]{3}[[:space:]]+[0-9]+[[:space:]]+[0-9:.]+[[:space:]]+([^[:space:]\[\(]+) ]]; then
|
|
[[ "${BASH_REMATCH[1]}" =~ $BLOCKLIST_RE ]] && continue
|
|
fi
|
|
|
|
# Colorize by <Level>: field; show all lines regardless of level
|
|
if [[ "$line" =~ \<(Error|ERROR|Fault|FAULT)\>: ]]; then
|
|
printf "%s%s%s\n%s\n" "$RED" "$line" "$RESET" "$SEP"
|
|
elif [[ "$line" =~ \<(Warning|WARNING)\>: ]]; then
|
|
printf "%s%s%s\n%s\n" "$YELLOW" "$line" "$RESET" "$SEP"
|
|
elif [[ "$line" =~ \<(Notice)\>: ]]; then
|
|
printf "%s%s%s\n%s\n" "$CYAN" "$line" "$RESET" "$SEP"
|
|
elif [[ "$line" =~ \<(Info)\>: ]]; then
|
|
printf "%s%s%s\n%s\n" "$GREEN" "$line" "$RESET" "$SEP"
|
|
elif [[ "$line" =~ \<(Debug)\>: ]]; then
|
|
printf "%s%s%s\n%s\n" "$DIM" "$line" "$RESET" "$SEP"
|
|
else
|
|
printf "%s\n%s\n" "$line" "$SEP"
|
|
fi
|
|
done
|