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
std-nslog is a shim that redirects stderr/stdout to the Apple unified logging system (`os_log`, the modern replacement for `NSLog`). This can be useful when deploying Python code as a standalone app on macOS or iOS, where stdout/stderr aren't easily visible for end users.
12
8
9
+
This functionality is baked into Python 3.14+ if you are using an embedded interpreter - set `config.use_system_logger = 1` when configuring the interpreter. The same functionality exists in all iOS CPython builds (where it is enabled by default).
10
+
13
11
## Usage
14
12
15
-
std-nslog will generally only be needed in the context of a bundled macOS or iOS application. You shouldn't ever need to install it yourself into a local virtual environment. However, just in case...
13
+
std-nslog will generally only be needed in the context of a bundled macOS application. You shouldn't ever need to install it yourself into a local virtual environment. However, just in case...
16
14
17
15
To install std-nslog:
18
16
@@ -22,8 +20,6 @@ Then, in your code, `import nslog`. This will install the shim. The file only ne
22
20
23
21
Once installed, all output written to stdout and stderr will be redirected to the unified logging system; stdout is logged at `OS_LOG_TYPE_DEFAULT`, and stderr at `OS_LOG_TYPE_ERROR`, so the two streams can be filtered separately in Console.app or `log stream`.
24
22
25
-
To associate the log entries with a specific subsystem and category (useful for filtering with `log stream --predicate 'subsystem == "..."'`), set the `STD_NSLOG_SUBSYSTEM` and `STD_NSLOG_CATEGORY` environment variables before importing `nslog`. If unset, the default system log is used.
26
-
27
23
## Why no pun?
28
24
29
25
While an obscure joke referencing apples and logs might be amusing, it would make no sense when it appeared in a Briefcase requirements file.
0 commit comments