-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Use os_log APIs to log PowerShell events on OSX #5310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| break; | ||
|
|
||
| case LOG_DEBUG: | ||
| os_log_debug(_log, MESSAGE_FORMAT, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.