LoggerKit 0.3.0

LoggerKit 0.3.0

Maintained by Kento Nagata.



LoggerKit 0.3.0

  • By
  • Kento Nagata

LoggerKit Pod version Build Status Maintainability Test Coverage

🤖 LoggerKit is logging framework that provides a format, log levels and multiple output destinations.

Usage

Using pre bundled logger class Logger, you can send log with log level like:

// Global context
let logger = Logger()
let stdout = StandardOut()
logger.register(destination: stdout)

// In some code
logger.debug("For debug")
logger.verbose("Something verbose")
logger.info("Something want to know")
logger.warning("Not expected, but not error")
logger.error("Something went wrong, fix this")

Customize

You can register custom destinations and log format. Log format belongs to destination. So you can set format by each destination.

// Create your log formatter
final class CustomLogFormatter: LogFormatterProtocol {
    func format(message: Any, level: LogLevel, context: LogContextProtocol) -> String {
        // Format message here
    }
}

// Create you log destination
final class CustomLogDestination: LogDestinationProtocol {
    var formatter: LogFormatterProtocol

    init(formatter: LogFormatterProtocol = CustomLogFormatter()) {
        self.formatter = formatter
    }

    func write(_ message: Any, level: LogLevel, context: LogContextProtocol) {
        let formatted = formatter.format(message, level: level, context: context)
        // You can write here how you want
    }
}

Installation

Using CocoaPods:

pod 'LoggerKit'

Development

In order to create Xcode project, run:

$ swift package generate-xcodeproj

Release

$ edit LoggerKit.podspec
# set the new version to 0.0.1
# set the new tag to 0.0.1
$ pod lib lint

$ git add -A && git commit -m "Release 0.0.1."
$ git tag '0.0.1'
$ git push --tags

$ pod trunk push LoggerKit.podspec

CocoaPods Guides