Created
October 30, 2019 12:26
-
-
Save vasilevkin/f1b5fa2fefe0a3b0dcd681f3f5e1dc02 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
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