Swiftpack.co - richardpiazza/Occurrence as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by richardpiazza.
richardpiazza/Occurrence 0.6.0
A swift logging library that integrates with `SwiftLog`
⭐️ 0
🕓 4 weeks ago
iOS macOS watchOS tvOS macCatalyst
.package(url: "https://github.com/richardpiazza/Occurrence.git", from: "0.6.0")


A swift logging library that integrates with SwiftLog.


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.6.0"))

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

import Occurrence


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
    .sink { entry in
        // process entry

// async/await
let task = Task {
    for await entry in Occurrence.logStreamer.stream {
        // process entry


Occurrence has many conveniences to enhance the overall logging experience.

The LoggableError protocol provides a way to easily convert errors to a Logger.Metadata representation. There are also extensions to the Logger instance that allow for passthrough of a LoggableError instance:

@LazyLogger("MyApp") var logger: Logger

enum AppError: LoggableError {
  case badData

func throwingFunction() throws {
  guard condition else {
    throw logger.error("Condition not met.", AppError.badData)


Stars: 0
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Occurrence 0.6.0
4 weeks ago

This release focuses on the introduction of the LoggableError protocol. LoggableErrors are designed to be easily converted to Logger.Metadata for writing the details of an error to the log. Conveniences are created to easily pass-through errors and reconstruct NSErrors from log entry metadata.

What's Changed

Full Changelog: https://github.com/richardpiazza/Occurrence/compare/0.5.0...0.6.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics