目录
目录README.md

Occurrence

A swift logging library that integrates with SwiftLog.

Twitter: @richardpiazza

Installation

Occurrence is distributed using the Swift Package Manager. To install it into a project, Use the Xcode ‘Swift Packages’ menu or add it as a dependency within your Package.swift manifest:

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/richardpiazza/Occurence.git", .upToNextMinor(from: "0.5.0"))
    ],
    ...
)

Then import the Occurrence packages wherever you’d like to use it:

import Occurrence

Usage

During you app initialization, call Occurrence.bootstrap(). This will configure the Swift LoggingSystem to use Occurrence as a LogHandler.

As a convenience to creating a Logger reference, use the LazyLogger property wrapper which will create a Logger with the specific label (Logger.Subsystem).

@LazyLogger("LoggerLabel") var logger: Logger

Occurrence also offers the ability to observe logging events as they are happening. This can also be useful in the case where entries may need to be proxied to a third-party service.

// Combine
Occurrence.logStreamer
    .publisher
    .sink { entry in
        // process entry
    }

// async/await
let task = Task {
    for await entry in Occurrence.logStreamer.stream {
        // process entry
    }
}
关于
120.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号