Skip to content

feat(ios): show the app's forwarded stdout and stderr - #6181

Open
rigor789 wants to merge 2 commits into
feat/ios-structured-logsfrom
feat/ios-stdio-logs
Open

rigor789 wants to merge 2 commits into
feat/ios-structured-logsfrom
feat/ios-stdio-logs

Conversation

@rigor789

@rigor789 rigor789 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Draft for the same reason as its base: it can't compile until ios-device-lib is released and bumped.

What is the current behavior?

print() output and, on devices, NSLog never reach the CLI, even with --log debug, because the app's stdio is /dev/null.

What is the new behavior?

  • Debug builds write forwardStdio to the app's package.json, next to logFormat.
  • Entries under the org.nativescript.stdio subsystem show from --log debug up, labeled stdout: or stderr:, like the rest of the app's native output and Xcode's console.
  • The default scope stays JS only.

If a device falls back to the syslog relay, forwarded lines arrive as ordinary syslog text with the subsystem visible in them. They aren't hidden by scope there.

Testing

Results are in NativeScript/ios#532, and unit tests cover the scope, labels, stitching and the key. Release prepare leaves the key out.

Part of a stack

Base: #6179. Needs NativeScript/ios#532.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4e00103-47bb-45fb-b581-2f75a923d262

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@NathanWalker NathanWalker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself (717c3604a, about +58/-2) looks correct. The stdio check runs before the runtime-entry check, stitching happens before labelling so a split line gets one prefix, and release builds never get the key. All unit tests pass locally once it's built against ios-device-lib#88.

Blocking

  1. The branch needs restacking. The +2664/40-file diff and the conflict come from this branch still carrying the pre-merge commits of #6176/#6177, while its base feat/ios-structured-logs was rebased onto the new main. Applying 717c3604a alone onto the current base gives no conflicts:
    git rebase --onto origin/feat/ios-structured-logs e9a3bd72e feat/ios-stdio-logs
    
    (The base #6179 also needs a rebase onto #6178's latest commit.)
  2. CI fails only on the missing ios-device-lib typings, same as #6179, so that is gated on the #88 release and bump.

Should-fix

  1. Syslog fallback (lib/services/ios-log-filter.ts:87-103): when the device falls back to syslog relay, forwarded stdout/stderr now shows at the default --log level, where it used to go to /dev/null. That breaks "default stays JS only". Have IOSLogFilter drop or relabel [org.nativescript.stdio: lines below debug level.
  2. Test gap (ios-simulator-log-provider.ts:146-147): nothing tests the subsystem/category mapping from log stream ndjson, because the tests build entries by hand. If that mapping breaks, stdio entries show by default as if they were JS output. A logStructuredLine test with a sample ndjson event would cover it.

Nits / questions

  • ios-log-entry.ts:65: if the stdio subsystem arrives without a category, ${entry.category} prints undefined:. Fall back to stdout.
  • prepare-controller.ts:530: forwardStdio/logFormat are applied after ...nsConfig, so a user can't opt out in a debug build. Is that intended?
  • Docs could note that stderr is only forwarded on devices.
  • On iOS versions where NSLog also goes to os_log, would --log debug print each NSLog twice (Foundation: and stderr:)?
  • Release notes should name the minimum runtime version (NativeScript/ios#532).

@NathanWalker
NathanWalker force-pushed the feat/ios-structured-logs branch from 071afe8 to aaff55c Compare November 16, 2026 03:27
@NathanWalker
NathanWalker marked this pull request as ready for review November 16, 2026 03:28
@NathanWalker

Copy link
Copy Markdown
Contributor

I restacked this onto #6179. Only your commit remains (a44f1ab3e); the stale #6176/#6177 commits are gone. I marked it ready and added 4e75758a3:

  • Syslog-relay fallback: lines tagged [org.nativescript.stdio:<stream>] are hidden unless --log is debug or higher. At debug and above they're relabelled stdout: / stderr:, the same as the structured path.
  • Missing category: a stdio entry without a category is labelled stdout: instead of undefined:.
  • Simulator test: a test now covers the ndjson subsystem/category mapping.

CI is green. One caveat: the syslog line format comes from your description and the simulator fixtures, not from a real device line. Please check it on hardware, and update the description: it still says these lines "aren't hidden by scope there".

rigor789 and others added 2 commits November 16, 2026 10:50
Debug builds ask the runtime to forward stdout and stderr through forwardStdio in the app's package.json. They arrive under the org.nativescript.stdio subsystem and show from --log debug, like the rest of the app's native output and as Xcode's console does, labeled with their stream.
…slog relay

When a device falls back to the syslog relay, forwarded stdout and stderr
lines arrive as plain text tagged "[org.nativescript.stdio:<stream>]" from
the NativeScript image, so the filter let them through at the default
--log level and the default scope was no longer JS only. They are now
shown from --log debug, as on the structured path, and labeled with their
stream the same way.

A stdio entry without a category is labeled stdout instead of
"undefined", and a test pins the simulator's ndjson subsystem and
category fields, since stdio entries missing them would show at the
default level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants