Skip to content

Commit 208d6e3

Browse files
[3.11] pythongh-150644: Tag Apple system log messages as public. (pythonGH-150645) (python#150739)
macOS 26 changed the default visibility of "dynamic" system messages. This changes the logging strategy to tag all messages as "public" so they are visible in the system log without special configuration. (cherry picked from commit 71fc4c6) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
1 parent 42aa80e commit 208d6e3

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
When system logging is enabled (with ``config.use_system_logger``, messages
2+
are now tagged as public. This allows the macOS 26 system logger to view
3+
messages without special configuration.

‎Python/pylifecycle.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,9 @@ apple_log_write_impl(PyObject *self, PyObject *args)
25222522

25232523
// Pass the user-provided text through explicit %s formatting
25242524
// to avoid % literals being interpreted as a formatting directive.
2525-
os_log_with_type(OS_LOG_DEFAULT, logtype, "%s", text);
2525+
// Using {public} ensures "dynamic" string messages are visible
2526+
// in the log without special configuration.
2527+
os_log_with_type(OS_LOG_DEFAULT, logtype, "%{public}s", text);
25262528
Py_RETURN_NONE;
25272529
}
25282530

0 commit comments

Comments
 (0)