https://github.com/kkebo/swift-log-playground
This Swift package is a logging backend for SwiftLog. It can be usable on Swift Playgrounds.
https://github.com/kkebo/swift-log-playground
logging playground swift swift-playground swift-playgrounds
Last synced: 7 months ago
JSON representation
This Swift package is a logging backend for SwiftLog. It can be usable on Swift Playgrounds.
- Host: GitHub
- URL: https://github.com/kkebo/swift-log-playground
- Owner: kkebo
- License: mit
- Created: 2021-11-09T18:11:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-10-17T19:21:49.000Z (9 months ago)
- Last Synced: 2025-11-15T10:06:46.726Z (8 months ago)
- Topics: logging, playground, swift, swift-playground, swift-playgrounds
- Language: Swift
- Homepage:
- Size: 86.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# LoggingPlayground
[](https://swiftpackageindex.com/kkebo/swift-log-playground)
[](https://swiftpackageindex.com/kkebo/swift-log-playground)
[](LICENSE)
This Swift package is a logging backend for [SwiftLog](https://github.com/apple/swift-log). It is usable on Swift Playground.
## Adding the dependency
You need to declare your dependency in your Package.swift:
```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:
```swift
.target(
name: "YourLibrary",
dependencies: [
.product(name: "LoggingPlayground", package: "swift-log-playground")
]
),
```
## Example (Playground Book or Xcode Playground)
```swift
import Logging
import LoggingPlayground
let logger = Logger(label: "main")
LoggingSystem.bootstrap { PlaygroundHandler(label: $0) }
logger.debug("The program started.")
```
## Example (App Project)
```swift
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()
}
}
}
```