SwiftSDK icon indicating copy to clipboard operation
SwiftSDK copied to clipboard

Use os_log instead of print for logging

Open jaanus opened this issue 4 years ago • 2 comments

Observed: Telemetry uses print-logging.

Expected: os_log is the modern recommended way of logging. Consider using that. https://developer.apple.com/documentation/os/logging/generating_log_messages_from_your_code

jaanus avatar Jun 16 '21 12:06 jaanus

That is a very good idea. Thanks for that. I'll double check if os_log is also available on Linux

winsmith avatar Jun 17 '21 07:06 winsmith

Good point. os_log isn’t available on Linux. https://github.com/apple/swift-log is the official thing to use on Linux. (And I suppose it works on other platforms too, some Server-Side Swift things like Vapor use it across all platforms, so AppTelemetry might too.)

jaanus avatar Jun 17 '21 07:06 jaanus

SwiftLog has the added ability of aggregating and sending logs up to a remote server for error monitoring.

I'm not sure it makes sense for this SDK to add a dependency though, and indeed it complicated the recent CocoaPods install.

Perhaps we support clients providing a simple log closure, defaulting to print if not overridden?

Sherlouk avatar Feb 21 '23 09:02 Sherlouk

Perhaps we support clients providing a simple log closure, defaulting to print if not overridden?

Yay for dependency injection. This sounds fine.

jaanus avatar Feb 21 '23 09:02 jaanus