ASL无法在swift

时间:2015-10-05 16:46:11

标签: ios swift logging

我试图通过我的代码阅读我的应用程序的日志,我确实找到this question帮助我开始并设法读取NSLog发布的日志,我的代码是

    func systemLogs() -> [String] {
    let q = asl_new(UInt32(ASL_TYPE_QUERY))
    let r = asl_search(nil, q)
    var m = asl_next(r)
    var log = [String]()
    while m != nil {
        let message = String.fromCString(asl_get(m, ASL_KEY_MSG))
        let timeStamp = String.fromCString(asl_get(m, "CFLog Local Time"))
        if let msg = message{
            log.append("\(timeStamp!) | \(msg)")
        }
        m = asl_next(r)
    }
    asl_release(r)
    return log
}

现在这仅适用于使用NSLog打印的日志,它不会使用swift的print()捕获任何内容。

有没有办法检索print()打印的消息?

0 个答案:

没有答案