Add dependency to your Package.swift
file:
.package(url: "https://github.com/arabianprinceee/SwiftLogger.git", exact: "x.x.x")
Then add SwiftLogger to your target's dependencies:
.target(name: "SwiftLogger", dependencies: ["SwiftLogger"]),
Then import package to use SwiftLogger in your app:
import SwiftLogger
And that's it!
Create an instance of Logger:
let defaultLogger = Logger.default
let customLogger = Logger(
configuration: LoggerConfiguration(
requiredLogs: [.logLevel, .message] // Pick the logs you need here
)
)
And then use it easily:
Text("Hello, world!")
.onAppear {
defaultLogger.log(.information, "This is default logger!")
customLogger.log(.information, "This is custom logger!")
}
Ben Mustafa Anas
📨 - anas.mustafa2301@gmail.com
👨🏽💻 - https://www.linkedin.com/in/anas-ben-mustafa-a29a5716b/
SwiftLogger is available under the MIT license. See the LICENSE file for more info.