Use os_log APIs to log PowerShell events on OSX#5310
Use os_log APIs to log PowerShell events on OSX#5310daxian-dbw merged 1 commit intoPowerShell:masterfrom dantraMSFT:libpsl-native/syslog
Conversation
| break; | ||
|
|
||
| case LOG_DEBUG: | ||
| os_log_debug(_log, MESSAGE_FORMAT, message); |
There was a problem hiding this comment.
For those different log types, do we need to check whether the type is enabled before calling the log method? What would happen in case the target type is not enabled?
There was a problem hiding this comment.
The check occurs in SysLogProvider.cs. The filters are passed into its constructor by PSSysLogProvider. Both Linux and Mac use the PowerShellProperties.json to define the filters (see JsonConfigFileAccessor in PropertyAccessor.cs)
There was a problem hiding this comment.
I don't see the API os_log_type_enabled exposed in this .cpp file, how does SysLogProvider.cs check if a log type is enabled? Does it enable all log types when creating the log object when calling os_log_create?
There was a problem hiding this comment.
It's not needed. Operational events are logged at the default level; which is enabled by default so we'll see the same output we would see in the event log.
https://developer.apple.com/documentation/os/os_log
I'd prefer to filter without interop calls at the risk that someone will change the configuration for powershell at the native layer and we make unneeded interop calls. We can address this later, if it becomes an issue.
There was a problem hiding this comment.
Thanks for the clarification. #Closed
|
@adityapatwardhan Would you mind taking a look at this? My syslog PR is blocked until this gets into main and the nuget package is published. Thanks. |
This change replaces calls to syslog with os_log on OSX. syslog calls on 10.12 was not producing log output and the functions do not report errors.
See #3766.
NOTE: PR #5144 depends on this PR.