This Swift package is a logging backend for SwiftLog. It is usable on Swift Playground.
You need to declare your dependency in your Package.swift:
.package(url: "https://github.com/kkebo/swift-log-playground", from: "0.2.0"),
and to your application/library target, add "LoggingPlayground" to your dependencies, e.g. like this:
.target(
name: "YourLibrary",
dependencies: [
.product(name: "LoggingPlayground", package: "swift-log-playground")
]
),
import Logging
import LoggingPlayground
let logger = Logger(label: "main")
LoggingSystem.bootstrap { PlaygroundHandler(label: $0) }
logger.debug("The program started.")
import Logging
import LoggingPlayground
import SwiftUI
let logger = Logger(label: "main")
@main
struct MyApp: App {
init() {
// Use swift-log-playground only if running on Swift Playground or Xcode Previews
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
LoggingSystem.bootstrap { PlaygroundHandler(label: $0) }
}
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}