Class: Everywhere::Commands::Logs
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Everywhere::Commands::Logs
- Defined in:
- lib/everywhere/commands/logs.rb
Overview
Tail the native shell's logs. iOS only so far: the Simulator's unified log, scoped to the shell process. Watches (log stream) by default; --last replays recent history (log show) and exits.
Constant Summary collapse
- PREDICATE =
The template contract fixes the product name (App.app), so the shell's process on the Simulator is always "App" — one predicate covers every Everywhere app without knowing which one is installed. Scoping to the process alone still yields ~100k lines/half hour of Apple-framework chatter (WebKit resource loads, activities); the default predicate keeps what a shell developer logs — NSLog (Foundation sender, no subsystem), Hotwire Native's subsystem, UIKit warnings — and drops the rest. --verbose falls back to the whole process.
'process == "App" AND eventType == logEvent AND NOT subsystem BEGINSWITH "com.apple"'- VERBOSE_PREDICATE =
'process == "App"'
Instance Method Summary collapse
-
#argv(udid, last: nil, verbose: false) ⇒ Object
simctl spawn runs the
logtool inside the Simulator runtime — the supported way to read a Simulator's unified log from the host. - #call(ios: false, last: nil, udid: nil, verbose: false) ⇒ Object
Instance Method Details
#argv(udid, last: nil, verbose: false) ⇒ Object
simctl spawn runs the log tool inside the Simulator runtime — the
supported way to read a Simulator's unified log from the host. log show
spells verbosity --info/--debug where log stream takes --level.
45 46 47 48 49 50 51 52 53 |
# File 'lib/everywhere/commands/logs.rb', line 45 def argv(udid, last: nil, verbose: false) argv = ["xcrun", "simctl", "spawn", udid, "log"] argv += if last ["show", "--last", last, *(verbose ? ["--info", "--debug"] : [])] else ["stream", *(verbose ? ["--level", "debug"] : [])] end argv + ["--style", "compact", "--predicate", verbose ? VERBOSE_PREDICATE : PREDICATE] end |
#call(ios: false, last: nil, udid: nil, verbose: false) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/everywhere/commands/logs.rb', line 31 def call(ios: false, last: nil, udid: nil, verbose: false, **) UI.die!("only the iOS Simulator is supported so far — run: every logs --ios") unless ios udid ||= Everywhere::Simulator.booted_udid UI.die!("no booted iOS Simulator — start one with `every dev --ios`") unless udid UI.step(last ? "iOS Simulator logs from the last #{UI.bold(last)}" : "watching iOS Simulator logs #{UI.dim("(Ctrl-C to stop)")}") exec(*argv(udid, last: last, verbose: verbose)) end |