brightdigit/FelinePine
Easy to use API for setting up logging and log categories across your architecture
Requirements
Apple Platforms
- Xcode 14.3.1 or later
- Swift 5.8 or later
- macOS 12 or later deployment targets
Linux
- Ubuntu 18.04 or later
- Swift 5.8 or later
Installation
Use the Swift Package Manager to install this library via the repository url:
https://github.com/brightdigit/FelinePine.gitUse version up to 1.0.0.
Usage
Getting Started
Create a LoggingSystem which defines the categories:
public enum BushelLogging: LoggingSystem {
public enum Category: String, CaseIterable {
case library
case data
case view
case machine
case application
case observation
case market
}
}The Category enum inside must have a RawType of String. Additionally if you wish to take advantage of automatically created Logger object, then you should also have to implment CaseIterable.
Now to use your new LoggingSystem in any type:
- Implement
FelineandPine - Define your
LoggingSystem - Define the
LoggingSystem.Category
internal struct VirtualMachine: Loggable {
internal typealias LoggingSystemType = BushelLogging
internal static let loggingCategory: BushelLogging.Category = .machine
func run () {
Self.logger.debug("Starting Run")
...
}
...
}Using the `Loggable` type
You can simplify by using the Loggable protocol to create protocol to use throughout your codebase:
public protocol BushelLoggable: FelinePine.Loggable where Self.LoggingSystemType == BushelLogging {}Now you can simply use the new Loggable type:
internal struct VirtualMachine: BushelLoggable {
internal static let loggingCategory: BushelLogging.Category = .machine
func run () {
Self.logger.debug("Starting Run")
...
}
}Further Documentation
Further documentation is available at the Swift Package Index.
License
This code is distributed under the MIT license. See the LICENSE file for more info.
Package Metadata
Repository: brightdigit/FelinePine
Stars: 3
Forks: 1
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: logging, swift, swift-log
README: README.md