Created
July 31, 2015 18:08
-
-
Save harlanhaskins/2953f201ecb5efb66137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func systemLogs() -> [[String: String]] { | |
let q = asl_new(UInt32(ASL_TYPE_QUERY)) | |
var logs = [[String: String]]() | |
let r = asl_search(nil, q) | |
var m = asl_next(r) | |
while m != nil { | |
var logDict = [String: String]() | |
var i: UInt32 = 0 | |
while true { | |
if let key = String.fromCString(asl_key(m, i)) { | |
let val = String.fromCString(asl_get(m, key)) | |
logDict[key] = val | |
i++ | |
} else { | |
break | |
} | |
} | |
m = asl_next(r) | |
logs.append(logDict) | |
} | |
asl_release(r) | |
return logs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment