Simple logging kit written in Swift, based on apple/swift-log framework.
- Bootstrap logging system globally
// AppDelegate.swift
import LoggingKit
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
static let logs = Box<[Log]>()
func application(..., didFinishLaunchingWithOptions...) -> Bool {
LoggingSystem.bootstrap(level: .info, output: Self.logs)
}
// ...
}
- Passthrough convenience types
// LoggingKit.swift
import LoggingKit
typealias Loggable = LoggingKit.Loggable
typealias Log = LoggingKit.Log
- Log
class ProfileViewModel: Loggable {
// ...
func logout() {
userManager.logout(
onSuccess: { [weak self] in
self?.coordinator.go(to: .signIn)
Self.logger.trace("User signed out.")
},
onFailure: { [weak self] error in
Self.logger.trace("User logout failed.")
Self.logger.info(.dump(error))
})
}
}
- Grab logs
class LoggingViewModel {
var logs: [Log] { AppDelegate.logs.content }
}
- See Examples for more.
Add the package to Your SwiftPM package dependencies:
.package(
url: "https://github.com/MakeupStudio/LoggingKit.git",
.upToNextMajor(from: "1.0.0-beta.1.1")
)
then add LoggingKit
dependency to your target.