-
Notifications
You must be signed in to change notification settings - Fork 48
OSLogWriter logs doesn't show up in console after process is detached from XCode #400
Description
I couldn't find any logs in console after my process is detached from Xcode (after app kill and restart). I found similar thread here: https://forums.developer.apple.com/forums/thread/727380
The source of this issue might be hidden in this part:
When running without Xcode, it will output Hello Cruel to the Console. I'd have to add Hello Cruel (planet, privacy: .public) for the full message to appear.
I assume, when using os_log with format specifiers (%s) and CvarArg, it treats the whole message as private, and that's why it's not outputting anything when run without Xcode.
I did a quick check and changing the DarwinLoggerActual implementation to always log public messages seems to solve this issue:
private object FixedDarwinLoggerActual : DarwinLogger {
@OptIn(ExperimentalForeignApi::class)
override fun log(osLogSeverity: UByte, message: String) {
_os_log_internal(
__dso_handle.ptr,
OS_LOG_DEFAULT,
osLogSeverity,
"%{public}s",
message
)
}
}