A custom logger implementation and Task Local helper for swift-log

Related tags

Logging LGN-Log
Overview

LGNLog

A custom logger implementation and TaskLocal helper for Swift-Log.

Why and how

This package provides two and a half things (and a small bonus):

  • TaskLocal support for Logger struct
  • A custom (and a pretty one) log handler implementation
  • Also it does import Logging so you don't have to (.mp4), just import LGNLog and it will work

TaskLocal

As per this package Logger now has @TaskLocal var current property which does precisely what you think it does: your app can call Logger.current in every place you can imagine to get a current logger, and you shouldn't bother creating new temporary loggers here and there. By default it's just a simple logger with label default. Sure enough, you can bind it to your configured logger for some async Task just like that:

var logger = Logger(label: "custom_label")
logger[metadataKey: "RequestID"] = "\(UUID())"
Logger.$current.withValue(logger) {
    Logger.current.info("hello")
}

And there you have it.

Custom implementation

Of course, default formatting isn't very pretty:

2021-10-23T17:51:14+0300 info custom_label : FileLine=main.swift:322 RequestID=00000000-1637-0034-1711-000000000000 Hello

so this package comes with a prettier formatting. You can enable it by calling:

LoggingSystem.bootstrap(LGNLogger.init)

Et voilà:

[2021-10-23 14:56:55 +0000 @ main.swift:322] [custom_label] [info]: Hello (metadata: {"FileLine":"main.swift:322","RequestID":"00000000-1637-0034-1711-000000000000"})

As a bonus, you can always change logging level:

LGNLogger.logLevel = .trace

and it will affect logging level of all loggers created after bootstrapping LGNLogger.

You might also like...
Simple network activity logger for iOS
Simple network activity logger for iOS

Reqres is a simple library for logging all requests and responses in your app. It supports Alamofire and also requests made via native NSURLSession. ⬆

Stock tradings Logger app for iOS
Stock tradings Logger app for iOS

Stock Logger Contributor: Name: Prof. Darren Takaki Author: Name: Ibrahim (Wusiman Yibulayin) Student ID: 0728356 Table of contents Description Gettin

An Alamofire network activity logger view
An Alamofire network activity logger view

📒 AlamofireLogbook An Alamofire network activity logger view Installation AlamofireLogbook is available through CocoaPods. To install it, simply add

📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.

TinyConsole TinyConsole is a tiny log console to display information while using your iOS app and written in Swift. Usage Wrap your Main ViewControlle

Log every incoming notification to view them again later, also includes attachments and advanced settings to configure

Vē Natively integrated notification logger Installation Add this repository to your package manager

Log messages to text files and share them by email or other way.
Log messages to text files and share them by email or other way.

LogToFiles How to log messages to text files and share them by email or share center. 1 - Add the Log.swift file to your App 2 - Just log the messages

Simply, Logify provides instant colorful logs to improve log tracking and bug tracing
Simply, Logify provides instant colorful logs to improve log tracking and bug tracing

Logify Simply, Logify provides instant colorful logs to improve log tracking and bug tracing. Why I need to use Logify? As discussed before in a lot o

A Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as
A Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as "the console")

CleanroomASL Notice: CleanroomASL is no longer supported The Apple System Log facility has been deprecated by Apple. As a result, we've deprecated Cle

A logging backend for swift-log that sends logging messages to Logstash (eg. the ELK stack)
A logging backend for swift-log that sends logging messages to Logstash (eg. the ELK stack)

LoggingELK LoggingELK is a logging backend library for Apple's swift-log The LoggingELK library provides a logging backend for Apple's apple/swift-log

Releases(0.4.0)
Owner
17:11 Games
17:11 Games
A lightweight Swift logger, uses `print` in development and `NSLog` in production. Support colourful and formatted output.

Loggerithm A lightweight Swift logger, uses print in Debug and NSLog in Production with colourful output. Why In Swift, we usually use print to log in

HongHao Zhang 270 Oct 8, 2022
Easy to use and lightweight logger for iOS, macOS, tvOS, watchOS and Linux in Swift.

Lighty Easy to use and lightweight logger for iOS, macOS, tvOS, watchOS and Linux in Swift. Screenshots Requirements Lighty Version Minimum iOS Target

Abdullah Selek 51 Dec 21, 2022
Tracker - A simple location logger app written in Swift and MVVM architecture

Tracker - A simple location logger app written in Swift and MVVM architecture

Loay Ashraf 1 Mar 12, 2022
A fancy logger yet lightweight, and configurable. 🖨

?? ?? Important: Printer can only print console logs if you're running an app in the Simulator. If you're running in a real device it will not print a

Hemang 66 Dec 7, 2022
A network logger for iOS and macOS projects.

OkLog for iOS and macOS OkLog-Swift is a network logger written in Swift highly inspired by simonpercic's original OkLog implementation to be used in

Diego Trevisan Lara 18 Dec 24, 2021
A simple logger for your swift applications.

AHQSLogger A simple logging system. Usage import AHQSLogger Use the following methods for loggging. Logging an information / debug You can log a simp

André Henrique da Silva 0 Dec 29, 2021
Bugfender SDK for iOS, a remote logger tailor-made for mobile

Bugfender SDK for iOS Bugfender is a cloud service to collect mobile application logs. Developers can control log sending programmatically and manuall

Bugfender 69 Dec 4, 2022
LogDog is designed to work out of the box, you can use the pre-configured logger anytime, anywhere

LogDog user-friendly logging apple/swift-log api compatible Usage LogDog is designed to work out of the box, you can use the pre-configured logger any

Luo Xiu 21 Aug 14, 2022
Logger for Xcode

CSwiftLog Usage Log.log("Message text without category") Log.my.log("Message text with custom category") Log.network.log("Message text with network ca

Andrew Firsenko 2 Nov 29, 2021