forked from invertase/react-native-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulator-logging.sh
More file actions
executable file
·56 lines (47 loc) · 2.88 KB
/
Copy pathsimulator-logging.sh
File metadata and controls
executable file
·56 lines (47 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Start or restart iOS simulator focused log stream and resource monitor (sourced by boot-simulator.sh).
set -uo pipefail
restart_simulator_logging() {
local with_stdout="${RNFB_SIM_LOG_STDOUT:-0}"
local record_screens="${RNFB_RECORD_SCREENS:-0}"
local log_dir="${RNFB_SIM_LOG_DIR:-.}"
local sim_app_log="${log_dir}/sim-app.log"
local resource_log="${log_dir}/resource-monitor.log"
local repo_root="${RNFB_REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)}"
# dyld logs its own fatal-launch-failure reason (e.g. "Symbol not found" / "Library not
# loaded") directly to the unified log via subsystem com.apple.dyld, independently of
# ReportCrash (which this workflow disables for CI performance -- see "Install yeetd and
# fix iOS perf issues" step -- so no .ips crash report is ever produced). Capture it here
# instead so launch-time dyld failures (e.g. release+spm launch timeouts) are diagnosable
# from sim-app.log without re-enabling the crash reporter daemon.
local log_predicate='process == "testing" OR (process == "SpringBoard" AND eventMessage CONTAINS "invertase") OR subsystem == "com.apple.dyld" OR eventMessage CONTAINS[c] "dyld"'
if ! xcrun simctl list devices booted 2>/dev/null | grep -q Booted; then
echo "[boot-status] phase=log_streams skipped=no_booted_simulator"
return 1
fi
echo "[boot-status] phase=log_streams_restart ts=$(date -u +%Y-%m-%dT%H:%M:%SZ) stdout=${with_stdout} record_screens=${record_screens} dir=${log_dir}"
pkill -f 'simctl spawn booted log stream' 2>/dev/null || true
pkill -f 'simctl io booted recordVideo' 2>/dev/null || true
pkill -f resource-monitor.sh 2>/dev/null || true
sleep 1
{
echo ""
echo "=== log stream restarted $(date -u +%Y-%m-%dT%H:%M:%SZ) predicate=${log_predicate} ==="
} >>"$sim_app_log" 2>/dev/null || : >"$sim_app_log"
if [[ "$record_screens" == "1" ]]; then
if [[ "$with_stdout" == "1" ]]; then
xcrun simctl io booted recordVideo --codec=h264 -f "${log_dir}/simulator.mp4" 2>&1 &
else
nohup sh -c "xcrun simctl io booted recordVideo --codec=h264 -f '${log_dir}/simulator.mp4' 2>&1 &" >/dev/null 2>&1 &
fi
fi
if [[ "$with_stdout" == "1" ]]; then
xcrun simctl spawn booted log stream --level debug --style compact \
--predicate "$log_predicate" 2>&1 | tee -a "$sim_app_log" &
else
nohup sh -c "xcrun simctl spawn booted log stream --level debug --style compact --predicate '${log_predicate}' >>'${sim_app_log}' 2>&1 &" >/dev/null 2>&1 &
fi
chmod +x "${repo_root}/.github/workflows/scripts/resource-monitor.sh"
RNFB_RESOURCE_MONITOR_LOG="$resource_log" nohup "${repo_root}/.github/workflows/scripts/resource-monitor.sh" >/dev/null 2>&1 &
echo "[boot-status] phase=log_streams_started sim_app_log=${sim_app_log} video=$([[ "$record_screens" == "1" ]] && echo "${log_dir}/simulator.mp4" || echo disabled) monitor=${resource_log}"
}