Home

Awesome

<!-- <img src="https://github.com/gokulnair2001/OSLogKit/assets/56252259/55aef060-6273-4f48-8bed-f46ad6db8681" width=20% height=20%> --> <img src="https://github.com/gokulnair2001/OSLogKit/assets/56252259/53164f76-9f0e-4dbf-8298-814424a427a0" width=20% height=20%>

OSLogKit

OSLogKit is a layer 2 framework developed on top of the native OSLog system, aiming to simplify the integration of OSLog into your project. Apple has done an excellent job in ensuring that OSLogging is straightforward and easy to use. However, when it comes to implementing OSLog in your codebase, can be challenging.

To address this, OSLogKit has been developed, further simplifying the process of adopting OSLog. One notable advantage of OSLogKit is that it offers additional functionalities not available in the native API.

OSLogKit has a variety of Modifiers which makes OSLogKit adoption very easy. Don't worry if your code base is in UIKit, you can still adopt it quickly.

Generic badge Generic badge Generic badge Generic badge Generic badge

Demo App

📔 Usage

⚙️ Initialisation

In order to use Logger you need to initialize the instance of Logger. OSLogKit supports a variety of Initialisation

🗳 Basic Initialisation

let logger = Logger()

🗳 Advance Initialisation

let logger = Logger(subSystem: "com.gokulnair.Test-OSKit", category: "ContentView")

🛠 Operations

Following are the methods which OSLogKit supports

💽 Single Capture/Logging

 func capture(level: OSLogType? = nil, message: String)

💽 Bulk Capturing/Logging

func captureInBulk(levels: [OSLogType] = [], messages: [String])

💽 Log Exporting

func exportLogs(forSubsystem subsystem: String = "", timeSpan span: OSLogSpan = .day(1), completion: @escaping((Result<[String], OSLogError>) -> ()))

OSLogSpan

NameCasesDescription
minutes.minute(x)Considers x minutes in past
hours.hour(x)Considers x hours in past
days.day(x)Considers x days in past

OSLogError

NameCaseDescription
Export Failure.exportFailure(let customString)Custom export failure error
Invalid Subsystem.invalidSubsystemOccurs when an Invalid Subsystem is used

SwiftUI Modifiers

🧩 CaptureLogOnAppear

func captureLogOnAppear(_ logger: OSLogKit, _ message: String, _ level: OSLogType = .default, _ perform: (() -> Void)? = nil)

🧩 CaptureBulkLogOnAppear

func captureBulkLogOnAppear(_ logger: OSLogKit, _ messages: [String], _ levels: [OSLogType], _ perform: (() -> Void)? = nil)

Other modifiers are

CaseDescription
.captureLogOnDisappearCaptures log on disappear
.captureBulkLogOnDisappearCaptures bulk log on disappear
.captureLogOnLongPressCaptures log on long press
.captureBulkLogOnLongPressCaptures bulk log on long press
.captureLogOnTapCaptures log on tap
.captureBulkLogOnTapCaptures bulk log on tap
.captureLogOnSubmitCaptures log on submit
.captureBulkLogOnSubmitCaptures bulk log on submit

⌨️ In Code Usage

SwiftUI

 VStack {
 // Some view
 }.captureLogOnTap(logger, "OSLogKit test log") {
  // additional on tap action (Optional)
 }

UIKit

logger.capture(message: "OSLogKit test log")

⚠️ Caution

📦 SPM

OSLogKit is available through Swift Package Manager. To add OSLogKit through SPM

https://github.com/gokulnair2001/OSLogKit
<img src="https://github.com/gokulnair2001/OSLogKit/assets/56252259/05f1688b-b62a-4114-a239-aa2f691f2e52" width=80% height=40%>

✨ Upcoming Features

⚖️ License

🪄 How to contribute?

<p align="center" width="100%"> Made with ❤️ in 🇮🇳 By Gokul Nair </p>