Skip to content

Instantly share code, notes, and snippets.

@harlanhaskins
Created July 31, 2015 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harlanhaskins/2953f201ecb5efb66137 to your computer and use it in GitHub Desktop.
Save harlanhaskins/2953f201ecb5efb66137 to your computer and use it in GitHub Desktop.
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