You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit db4fdaa
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(ios): structured app logs that follow relaunches (#6179)
* feat(ios): structured app logs that follow relaunches
Devices stream com.apple.os_trace_relay and simulators use log stream, both selected by executable name, so logs survive closing and reopening the app. --log picks the scope: JS output by default, the app's native logs without debug entries with debug, everything with trace or all. Without a new enough ios-device-lib, devices fall back to the syslog relay.
Debug builds ask the runtime for chunk markers through logChunkMarkers in the app's package.json, and the CLI stitches split messages back together per process and thread.
* feat(ios): reassemble split app logs from the runtime's piece headers
Asks the runtime for log format 1 through the logFormat key of the app's
package.json, in place of logChunkMarkers.
In format 1, each piece of a message the runtime had to split is logged as
"[ns <id> <index>/<count>] <piece>", where the pieces are consecutive
slices of the message. The stitcher now collects pieces by process and
message id, prints the message as soon as its last piece arrives, and
after 500 ms prints what it has with "<…lost…>" where pieces never
arrived. A message can no longer be joined onto another one whose last
piece os_log dropped.
Pieces are joined before the entry is turned into text, so the repeated
console prefix no longer has to be stripped. The syslog fallback, which
doesn't reassemble, removes the headers and shows the pieces as lines.
* fix(ios): bound split-message headers and flush a superseded message
The piece header is matched against any entry the NativeScript framework
logs, app output included, and its count sized an array up front. A line
such as "[ns 1 1/9999999999] x" made that allocation throw and crash the
CLI, and a count in the tens of millions stalled the event loop. Headers
now only match the digit counts the runtime writes (ids of up to 8 hex
digits, counts of up to 7 decimal ones), anything longer passes through
as an ordinary message, and pieces are kept by index so a large count
costs nothing until pieces actually arrive.
When the same id showed up again with a different count, the pending
message was replaced but its timer kept running: it later dropped the
new message's pieces and printed the old one. The old message is now
printed straight away, with its missing pieces marked as lost, and its
timer is cleared.
* fix(ios): trace what the simulator's log stream writes to stderr
With structured simulator logs only stdout was read, so an error from
log stream, such as a rejected predicate, disappeared without a trace and
the app's logs silently stayed empty.
* fix(ios): keep the unique bundle suffix single and honour a global FULL log level
The native watcher now passes prepareData when it rewrites the runtime
package.json. That write reads main back from the already-emitted file,
so with uniqueBundle set an App_Resources change turned "bundle.123"
into "bundle.123.123", an entrypoint that doesn't exist. The suffix is
only added when main doesn't already carry it.
Structured entries decided between the default scope and FULL from the
device's own log level only, so setLogLevel("FULL") for all devices,
which the syslog path honours, was ignored. They now fall back to the
global level the same way.
* docs(ios): explain --log levels for device logs
Document the levels that scope the app's output in run, debug and test ios, including all, and that --log also makes the CLI's own output verbose.
* refactor(ios): drop the startDeviceLogStream availability check
ios-device-lib is pinned to 0.10.0, which always has it. Also give IiOSLogEntry and IiOSLogStreamOptions their own doc comments and describe what pid is used for.
* feat(visionos): ask for the structured log format in debug builds
visionOS devices and simulators already go through the same structured log path as iOS, and the runtime reads logFormat in code shared by both targets.
---------
Co-authored-by: Eduardo Speroni <edusperoni@gmail.com>
Co-authored-by: Nathan Walker <walkerrunpdx@gmail.com>
Copy file name to clipboardExpand all lines: docs/man_pages/project/testing/debug-ios.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ Attach the debug tools to a running app in the iOS simulator | `$ ns debug ios -
30
30
*`--debug-brk` - Prepares, builds and deploys the application package on a device or in a simulator, runs the app, launches the developer tools of your Safari browser and stops at the first code statement.
31
31
*`--start` - Attaches the debug tools to a deployed and running app and launches the developer tools of your Safari browser.
32
32
*`--no-client` - If set, the NativeScript CLI attaches the debug tools but does not launch the developer tools in Safari. Could be used on already started Safari Web Inspector.
33
+
*`--log <Level>` - Sets how much of the application output is printed. By default only its JavaScript output is shown. `debug` adds everything else the app logs - its native code and the system frameworks it uses, like Xcode's console. `trace` and `all` add debug level entries as well. `--log` also sets the verbosity of the CLI's own output, so each of these levels prints the CLI's diagnostic messages too.
33
34
*`--timeout` - Sets the number of seconds that NativeScript CLI will wait to find the inspector socket port from device's logs. If not set, the default timeout is 10 seconds.
34
35
*`--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
35
36
*`--clean` - If set, forces the complete rebuild of the native application.
Copy file name to clipboardExpand all lines: docs/man_pages/project/testing/run-ios.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ Start an emulator with specified device identifier and sdk | `$ ns run ios [--de
33
33
*`--emulator` - If set, runs the app in all available and configured ios simulators. It will start a simulator if none are already running.
34
34
*`--sdk` - Specifies the target simulator's sdk.
35
35
*`--justlaunch` - If set, does not print the application output in the console.
36
+
*`--log <Level>` - Sets how much of the application output is printed. By default only its JavaScript output is shown. `debug` adds everything else the app logs - its native code and the system frameworks it uses, like Xcode's console. `trace` and `all` add debug level entries as well. `--log` also sets the verbosity of the CLI's own output, so each of these levels prints the CLI's diagnostic messages too.
36
37
*`--clean` - If set, forces the complete rebuild of the native application.
37
38
*`--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
38
39
*`--release` - If set, produces a release build by running webpack in production mode and native build in release mode. Otherwise, produces a debug build.
Copy file name to clipboardExpand all lines: docs/man_pages/project/testing/test-ios.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ Run tests in the iOS Simulator | `$ ns test ios --emulator [--watch] [--debug-br
27
27
*`--device` - Specifies the serial number or the index of the connected device on which you want to run tests. To list all connected devices, grouped by platform, run `$ ns device`. You cannot set `--device` and `--emulator` simultaneously. `<Device ID>` is the device index or identifier as listed by the `$ ns device` command.
28
28
*`--emulator` - Runs tests on the iOS Simulator. You cannot set `--device` and `--emulator` simultaneously.
29
29
*`--debug-brk` - Runs the tests under the debugger. The debugger will break just before your tests are executed, so you have a chance to place breakpoints.
30
+
*`--log <Level>` - Sets how much of the application output is printed. By default only its JavaScript output is shown. `debug` adds everything else the app logs - its native code and the system frameworks it uses, like Xcode's console. `trace` and `all` add debug level entries as well. `--log` also sets the verbosity of the CLI's own output, so each of these levels prints the CLI's diagnostic messages too.
30
31
*`--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `ns migrate`.
0 commit comments