Skip to content

Add option for redirecting stdout and stderr to the system log #126821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
freakboy3742 opened this issue Nov 14, 2024 · 4 comments · Fixed by #127592
Closed

Add option for redirecting stdout and stderr to the system log #126821

freakboy3742 opened this issue Nov 14, 2024 · 4 comments · Fixed by #127592
Labels
OS-ios OS-mac type-feature A feature request or enhancement

Comments

@freakboy3742
Copy link
Contributor

freakboy3742 commented Nov 14, 2024

Feature or enhancement

Proposal:

Python currently assumes that stdout and stderr are streams that are universally available. This is true for most systems.
However, on iOS, stdout/stderr content is only really visible while in Xcode. When an app is running in the wild, the expectation is that the app will use the system log for all output needs.

On iOS, stdout and stderr should be automatically directed to the system log (with appropriate log levels). This matches what Android does by default (see #118063). Existing iOS apps in the wild need to use a shim such as std-nslog to ensure that stdout/err content can be loaded at runtime. This also complicates the iOS testing story, as stdout/stderr content is only visible at the end of a test run, rather than being streamable content as the test runs.

As iOS and macOS share an underlying logging framework, it should also be possible to have this functionality on macOS as well (on an opt-in basis when the Python interpreter is configured). This would be useful for Python code that has been embedded into a native macOS GUI app. At present, stdout and stderr are essentially inaccessible for apps of this type.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@freakboy3742
Copy link
Contributor Author

Addressing this is likely a pre-requisite for addressing #126925.

@terryjreedy
Copy link
Member

The PR linked to the issue is still open. Either the PR should be closed or merged, or the issue re-opened.

@freakboy3742
Copy link
Contributor Author

@terryjreedy The feature was implemented in #127592; the linked open PR is a documentation update that is specific to this feature that is waiting on a review.

@terryjreedy
Copy link
Member

If it still needed review, I would re-open. But since I think it ready to merge, not.

freakboy3742 added a commit that referenced this issue Dec 10, 2024
…127755)

Add versionadded annotation to use_system_logger feature.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 10, 2024
…ture. (pythonGH-127755)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
freakboy3742 added a commit that referenced this issue Dec 10, 2024
…ature. (GH-127755) (#127806)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
freakboy3742 added a commit to freakboy3742/cpython that referenced this issue Dec 13, 2024
…er feature. (pythonGH-127755) (python#127806)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
freakboy3742 added a commit to freakboy3742/cpython that referenced this issue Dec 13, 2024
…ger feature. (pythonGH-127755) (python#127806)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
freakboy3742 added a commit to freakboy3742/cpython that referenced this issue Dec 13, 2024
…ger feature. (pythonGH-127755) (python#127806)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
freakboy3742 added a commit to freakboy3742/cpython that referenced this issue Dec 13, 2024
…ger feature. (pythonGH-127755) (python#127806)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
freakboy3742 added a commit to freakboy3742/cpython that referenced this issue Dec 13, 2024
…ture. (python#127755)

Add versionadded annotation to use_system_logger feature.
freakboy3742 added a commit to freakboy3742/cpython that referenced this issue Dec 13, 2024
…ger feature. (pythonGH-127755) (python#127806)

Add versionadded annotation to use_system_logger feature.
(cherry picked from commit 5121685)

Co-authored-by: Russell Keith-Magee <[email protected]>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 8, 2025
…ture. (python#127755)

Add versionadded annotation to use_system_logger feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-ios OS-mac type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants