【发布时间】:2017-03-09 10:44:09
【问题描述】:
在 iOS 10.0 中已弃用:os_log(3) 已取代 asl(3)
所以 iOS 10.0 显然弃用了 asl(Apple 系统日志)api,并用非常有限的 os_log api 取而代之。
我使用类似于下面的代码 sn-p 的东西来读出正在运行的应用程序的日志写入,以显示在应用程序的 uitextview 中 - 现在它充满了弃用警告。有谁知道使用新的 os_log api 读取打印日志的方法?因为我只看到一个写的api(https://developer.apple.com/reference/os/1891852-logging)。
import asl
let query = asl_new(UInt32(ASL_TYPE_QUERY))
let response = asl_search(nil, query)
while let message = asl_next(response) {
var i: UInt32 = 0
let key = asl_key(message, i)
print(asl_get(message, key))
...
}
在@Will Loew-Blosser 回答后编辑
https://developer.apple.com/videos/play/wwdc2016/721/ 很好地解释了未来日志记录会发生什么。最大的好处是日志以某种压缩格式放置,并且仅由新的控制台应用程序扩展。这几乎让我的任务毫无希望。
视频中的人 (Steve Szymanski) 提到“所有 ASL 日志记录 API 都被新 API 取代”和“用于搜索新日志数据的新 API 不会在此版本中公开”,又名 asl_search。这正是我想要的!
他还提到我即将推出一个 swift API。
【问题讨论】:
标签: ios swift logging deprecated