Swiftpack.co -  Alexander-Ignition/OSLogging as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Alexander-Ignition/OSLogging
swift-log + os.log
.package(url: "https://github.com/Alexander-Ignition/OSLogging.git", from: "1.0.2")

OSLogging

SPM compatible GitHub license

OSLog logging backend for swift-log

Features

  • ☑ Configure OSLog
  • ☑ Mapping logging levels of Logger.Level to OSLogType
  • ☑ Customize metadata formatter

Instalation

Add dependency to Package.swift...

.package(url: "https://github.com/Alexander-Ignition/OSLogging", from: "1.0.0"),

... and your target

.target(name: "ExampleApp", dependencies: ["OSLogging"]),

Usage

Override LoggingSystem with default OSLog.

LoggingSystem.bootstrap { _ in OSLogHandler() }

let logger = Logger(label: "com.example.app")
logger.info("i found you!")
// 2019-10-20 08:47:35.498086+0300 ExampleApp[6533:150683] i found you!

Сhoose subsystems and categories for different parts of the application

let logger = Logger(label: "com.exaple.app") { label in
    OSLogHandler(subsystem: label, category: "auth")
}

logger.info("loose control")
// 2019-10-20 08:47:35.498582+0300 ExampleApp[6533:150683] [auth] loose control

Custom metadata format

var logger = Logger(label: "com.exaple.app") { label in
    var hanlder = OSLogHandler(subsystem: label, category: "session")
    hanlder.formatter = { metadata in
        metadata.map { "\($0):\($1)" } .joined(separator: ", ")
    }
    return hanlder
}
logger[metadataKey: "request-id"] = "1"
logger[metadataKey: "session-id"] = "a"

logger.warning("catch me if you can")
// 2019-10-20 08:47:35.499106+0300 ExampleApp[6533:150683] [session] session-id:a, request-id:1 catch me now

GitHub

link
Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Release Notes

1.0.2
2 weeks ago

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