Lightweight utilities for making OSLog more pleasant. Honestly, this is not a lot of code. But, it's handy and I've come to apperciate it.
Swift Package Manager:
dependencies: [
.package(url: "https://github.com/ChimeHQ/UnifiedLoggingPlus")
]
Simple helper for Logger
.
let logger = Logger(category: "MyCategory") // uses OSLog(category:)
More consise logging statements.
let log = OSLog(bundleIdScopedCategory: "MyCategory")!
let otherLog = OSLog(category: "MyCategory") // defaults to using bundle-id for scoping
log.debug("A")
log.info("B: %{public}@", value)
do {
try thingThatThrows()
} catch {
log.error("print error type without conversion: %{public}@", error)
}
Signpost
is a simple type that encapsulates os_signpost
calls, and a bunch of simple extension on OSLog
.
let log = OSLog(bundleIdScopedCategory: "MyCategory")!
log.debug("concise log statements")
let result = log.signpostWithin("name") {
// this gets measured by the signpost
}
We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.