Skip to content

Conversation

@dantraMSFT
Copy link
Contributor

@dantraMSFT dantraMSFT commented Nov 2, 2017

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.

break;

case LOG_DEBUG:
os_log_debug(_log, MESSAGE_FORMAT, message);
Copy link
Member

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?

Copy link
Contributor Author

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)

Copy link
Member

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?

Copy link
Contributor Author

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.

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.

Copy link
Member

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

@dantraMSFT
Copy link
Contributor Author

@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.

@daxian-dbw daxian-dbw merged commit ed499ce into PowerShell:master Nov 3, 2017
@dantraMSFT dantraMSFT deleted the libpsl-native/syslog branch November 3, 2017 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants