Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vasilevkin/f1b5fa2fefe0a3b0dcd681f3f5e1dc02 to your computer and use it in GitHub Desktop.
Save vasilevkin/f1b5fa2fefe0a3b0dcd681f3f5e1dc02 to your computer and use it in GitHub Desktop.
import os.log
import os.signpost
let networkLog = OSLog(subsystem: "com.example.app.reader", category: "Articles")
let signpostID = OSSignpostID(log: networkLog)
func loadArticles() throws -> [Article] {
let decoder = JSONDecoder()
return try files.map { file in
os_signpost(type: .begin, log: networkLog, name: "Read File",
signpostID: signpostID,"%{public}s", file.path)
let data = try file.read()
os_signpost(type: .end, log: networkLog, name: "Read File",
signpostID: signpostID,"%{public}s", file.path)
os_signpost(type: .begin, log: networkLog, name: "Parse Article from File",
signpostID: signpostID,"%{public}s", file.path)
let article = try decoder.decode(Article.self, from: data)
os_signpost(type: .end, log: networkLog, name: "Parse Article from File",
signpostID: signpostID,"%{public}s", file.path)
return article
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment