I am unsure where to post this…but iOS 10 is introducing a new API for activity 
tracing and logging.

The API has been “Swift-ified” a little, but it still is a little awkward to 
use:

os_log("Sender: %{public}@", log: ViewController.ui_log, type: .debug, sender)

(This is taken from: 
https://developer.apple.com/library/prerelease/content/samplecode/Logging/Introduction/Intro.html#//apple_ref/doc/uid/TP40017510
 
<https://developer.apple.com/library/prerelease/content/samplecode/Logging/Introduction/Intro.html#//apple_ref/doc/uid/TP40017510>)

Note: the {public} modifier above does not work in swift but does in 
Objective-C. I have filed a radar for this.

A few things:
• This looks like how the Dispatch APIs use to look: very C-like which was made 
to be much better in The Great Renaming
• Cannot use Swift’s string interpolation, resulting in the arguments being 
passed in at the end

For reference, this is what it looks like in Objective-C, showing that SOME 
renaming has occurred: 
os_log_debug(ui_log, "Sender: %{public}@", sender);

This might look more Swift-like:
uiLog.log("Sender: %{public}\(sender)”, type: .debug)
* Makes “log” a method on an OSLog object 
• Uses string interpolation


I hope this isn’t too late AND maybe we will see something more complete when 
the GM is released, but this seems important to correct and get right BEFORE it 
is released.

The OS framework is also suppose to have new activity tracing API but it is not 
yet exposed in Swift. This is worrisome as the GM is allegedly dropping next 
week.

If this is pushed aside: what happens when it is released as it is? Are we 
stuck with this API? Can it be corrected in Swift 4 (breaking changes etc…)?

Brandon
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to