Swiftpack.co -  nneuberger1/swift-log-console-colors as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
nneuberger1/swift-log-console-colors
This is a small SwiftLog API compatible library that shows more color in the Xcode console for easier identification of errors, warnings, etc in the console.
.package(url: "https://github.com/nneuberger1/swift-log-console-colors.git", from: "1.0.3")

swift-log-console-colors

This is a small SwiftLog API compatible library that implements colors to make it easier for finding specific logs in the XCode console.

It is an implementation of a LogHandler as defined by the Swift Server Working Group logging API.

Usage

Add https://github.com/nneuberger1/swift-log-console-colors.git as a dependency in your Package.swift.

Then, during your application startup, do:

import Logging
import SwiftLogConsoleColors

// Initialize the logger
ColorStreamLogHandler.standardOutput(label: label, logIconType: .cool)

Elsewhere in your application, when you need to log, do:

// Create a logger (or re-use one you already have)
let logger = Logger(label: "MyApp")

// Log!
logger.info("Hello World!")

The output will look like this if passing in .cool

2021-05-09T16:13:30-0500 🐛 debug thingsAboveAdmin : Testing log levels..
2021-05-09T16:13:30-0500 ℹ️ info thingsAboveAdmin : Testing log levels..
2021-05-09T16:13:30-0500 📖 notice thingsAboveAdmin : Testing log levels..
2021-05-09T16:13:30-0500 ⚠️ warning thingsAboveAdmin : Testing log levels..
2021-05-09T16:13:30-0500 ⚡ critical thingsAboveAdmin : Testing log levels..
2021-05-09T16:13:30-0500 🔥 error thingsAboveAdmin : Testing log levels..

The output will look like this if passing in .rainbow

2021-05-09T16:17:07-0500 🟪 debug thingsAboveAdmin : Testing log levels..
2021-05-09T16:17:07-0500 🟦 info thingsAboveAdmin : Testing log levels..
2021-05-09T16:17:07-0500 🟩 notice thingsAboveAdmin : Testing log levels..
2021-05-09T16:17:07-0500 🟨 warning thingsAboveAdmin : Testing log levels..
2021-05-09T16:17:07-0500 🟧 critical thingsAboveAdmin : Testing log levels..
2021-05-09T16:17:07-0500 🟥 error thingsAboveAdmin : Testing log levels..

GitHub

link
Stars: 0
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API