Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

ChimeHQ/UnifiedLoggingPlus

Repository files navigation

Build Status License Platforms

UnifiedLoggingPlus

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.

Integration

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/ChimeHQ/UnifiedLoggingPlus")
]

Usage

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
}

Suggestions or Feedback

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.