I recently had cause to futz around with using the new unified logging mechanism (
<os/log.h>
) from kernel code and I learnt some things that I figured I might share:
Within the kernel
always returnsos_log_create
, so you can’t create your own logging handle. You have to useNULL
.OS_LOG_DEFAULT
This limits your ability to configure logging. You always get the standard configuration, meaning that
andOS_LOG_TYPE_INFO
always go to memory.OS_LOG_TYPE_DEBUG
The channel used by kernel logging is shared by all kernel code.
If kernel code logs too frequently, log messages will be dropped (this is no different from previous kernel logging mechanisms, and is necessary because the kernel can’t block waiting for the user space daemon to clear the log).
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"