added initial script and readme

This commit is contained in:
2026-05-15 07:20:52 -05:00
commit 62252a6abf
3 changed files with 143 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
# applog
A shell script that wraps `idevicesyslog` to show clean, colorized log output for a specific iOS app. Cuts through the noise of the full system log and surfaces only lines relevant to your app or bundle ID.
## Requirements
### macOS
```sh
brew install usbmuxd libimobiledevice
```
| Package | Role |
|---------|------|
| `usbmuxd` | USB multiplexer daemon — manages the connection between the host and iOS devices over USB |
| `libimobiledevice` | Provides `idevicesyslog` and other iOS communication tools |
> On macOS, Apple ships its own `usbmuxd` as part of the OS. If `idevicesyslog` works without the brew version, you can skip `usbmuxd`.
### Linux
```sh
# Debian/Ubuntu
sudo apt install usbmuxd libimobiledevice-utils
# Arch
sudo pacman -S usbmuxd libimobiledevice
```
### iOS device setup
1. **Trust the host machine** — connect the device, tap *Trust* on the prompt, and enter your passcode.
2. **Enable Developer Mode** (iOS 16+) — Settings → Privacy & Security → Developer Mode. The device will reboot.
3. **Pair the device** (if prompted):
```sh
idevicepair pair
```
### Other
- bash 3.2+
- USB cable (wireless/Wi-Fi connections are not supported by `idevicesyslog`)
## Usage
```sh
./applog.sh <bundle-id-prefix|process-name>
```
**Examples:**
```sh
./applog.sh com.mycompany.myapp
./applog.sh MyApp
```
Press `Ctrl+C` to stop.
## Output
Each matched line is colorized by log level and separated by a visual rule:
| Color | Level |
|--------|-------|
| 🔴 Red | `<Error>`, `<Fault>` |
| 🟡 Yellow | `<Warning>` |
| 🔵 Cyan | `<Notice>` |
| 🟢 Green | `<Info>` |
| Gray | `<Debug>` |
## How filtering works
Lines are included if they contain the filter string anywhere — the app's own process logs, plus system services acting on its behalf (network, Bluetooth, etc.).
A blocklist of known noisy system daemons (`runningboardd`, `tccd`, `launchd`, and others) is excluded even when they reference your bundle ID, since those lines reflect system bookkeeping rather than app behavior.
To suppress additional processes, add them to `BLOCKLIST_RE` near the top of the script.
## Installation
```sh
chmod +x applog.sh
# optionally move somewhere on your PATH
cp applog.sh /usr/local/bin/applog
```
Executable
+58
View File
@@ -0,0 +1,58 @@
#!/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
Binary file not shown.

After

Width:  |  Height:  |  Size: 743 KiB