Build Status License Platforms

UnifiedLoggingPlus

轻量级实用工具,使 OSLog 更易于使用。 老实说,这不是很多代码。 但是,它很方便,而且我已经开始欣赏它了。

⚠️在这一点上,您可能应该直接使用 Logger 类型。

集成

Swift 包管理器

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

用法

Logger 的简单助手。

let logger = Logger(category: "MyCategory") // uses OSLog(category:)

更简洁的日志语句。

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 是一种简单的类型,封装了 os_signpost 调用,以及 OSLog 上的一堆简单扩展。

let log = OSLog(bundleIdScopedCategory: "MyCategory")!

log.debug("concise log statements")

let result = log.signpostWithin("name") {
    // this gets measured by the signpost
}

建议或反馈

我们很乐意听取您的意见! 请通过 issue 或 pull request 与我们联系。

请注意,本项目根据 贡献者行为准则 发布。 参与本项目即表示您同意遵守其条款。