FelinePine

main

Easy to use API for setting up logging and log categories across your architecture
brightdigit/FelinePine

FelinePine

FelinePine

Type-wide categorized logging.

SwiftPM Twitter GitHub GitHub issues GitHub Workflow Status

Codecov CodeFactor Grade codebeat badge Code Climate maintainability Code Climate technical debt Code Climate issues Reviewed by Hound

Table of Contents

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:

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
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.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

Last updated: Mon Mar 25 2024 05:27:26 GMT-0900 (Hawaii-Aleutian Daylight Time)