[3.14] gh-150644: Tag Apple system log messages as public. (GH-150645) (#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 71fc4c66d3)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
This commit is contained in:
Miss Islington (bot) 2026-06-02 00:51:07 +02:00 committed by GitHub
parent adec1cb043
commit 13bb7f7cd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,3 @@
When system logging is enabled (with ``config.use_system_logger``, messages
are now tagged as public. This allows the macOS 26 system logger to view
messages without special configuration.

View file

@ -2972,7 +2972,9 @@ apple_log_write_impl(PyObject *self, PyObject *args)
// Pass the user-provided text through explicit %s formatting
// to avoid % literals being interpreted as a formatting directive.
os_log_with_type(OS_LOG_DEFAULT, logtype, "%s", text);
// Using {public} ensures "dynamic" string messages are visible
// in the log without special configuration.
os_log_with_type(OS_LOG_DEFAULT, logtype, "%{public}s", text);
Py_RETURN_NONE;
}