https://github.com/brightdigit/felinepine
Easy to use API for setting up logging and log categories across your architecture
https://github.com/brightdigit/felinepine
logging swift swift-log
Last synced: about 1 year ago
JSON representation
Easy to use API for setting up logging and log categories across your architecture
- Host: GitHub
- URL: https://github.com/brightdigit/felinepine
- Owner: brightdigit
- License: mit
- Created: 2023-05-18T22:28:05.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-14T02:00:13.000Z (over 1 year ago)
- Last Synced: 2025-03-27T08:02:07.632Z (about 1 year ago)
- Topics: logging, swift, swift-log
- Language: Swift
- Homepage:
- Size: 119 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
FelinePine
Type-wide **cat**egorized **log**ging.
[](https://swift.org)
[](http://twitter.com/brightdigit)



[](https://swiftpackageindex.com/brightdigit/FelinePine)
[](https://swiftpackageindex.com/brightdigit/FelinePine)
[](https://codecov.io/gh/brightdigit/FelinePine)
[](https://www.codefactor.io/repository/github/brightdigit/FelinePine)
[](https://codebeat.co/projects/github-com-brightdigit-felinepine-main)
[](https://codeclimate.com/github/brightdigit/FelinePine)
[](https://codeclimate.com/github/brightdigit/FelinePine)
[](https://codeclimate.com/github/brightdigit/FelinePine)
[](https://houndci.com)
# Table of Contents
* [Introduction](#introduction)
* [Requirements](#requirements)
* [Installation](#installation)
* [Usage](#usage)
* [Getting Started](#getting-started)
* [Using the Loggable type](#using-the-loggable-type)
* [Further Documentation](#further-documentation)
* [License](#license)
# Introduction
**FelinePine** provides an 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.git
```
Use version up to `1.0.0`.
# Usage
## Getting Started
Create a `LoggingSystem` which defines the categories:
```swift
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:
1. Implement `Feline` and `Pine`
2. Define your `LoggingSystem`
3. Define the `LoggingSystem.Category`
```swift
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:
```swift
public protocol BushelLoggable: FelinePine.Loggable where Self.LoggingSystemType == BushelLogging {}
```
Now you can simply use the _new_ `Loggable` type:
```swift
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.](https://swiftpackageindex.com/brightdigit/FelinePine/1.0.0/documentation/FelinePine)
# License
This code is distributed under the MIT license. See the [LICENSE](https://github.com/brightdigit/FelinePine/LICENSE) file for more info.