Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ericlewis/swift-log-variadic-bootstrap
Variadic bootstrapping function for SwiftLog.
https://github.com/ericlewis/swift-log-variadic-bootstrap
ios logging macos swift swift-log tvos watchos
Last synced: about 1 month ago
JSON representation
Variadic bootstrapping function for SwiftLog.
- Host: GitHub
- URL: https://github.com/ericlewis/swift-log-variadic-bootstrap
- Owner: ericlewis
- License: mit
- Created: 2022-01-15T15:38:06.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-15T15:48:10.000Z (almost 3 years ago)
- Last Synced: 2024-09-13T10:55:53.027Z (2 months ago)
- Topics: ios, logging, macos, swift, swift-log, tvos, watchos
- Language: Swift
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SwiftLogVariadicBootstrap
[![Build & Test](https://github.com/ericlewis/swift-log-variadic-bootstrap/actions/workflows/ci.yml/badge.svg)](https://github.com/ericlewis/swift-log-variadic-bootstrap/actions/workflows/ci.yml)Variadic bootstrap function for [SwiftLog](https://github.com/apple/swift-log).
Basically bridges `LoggingSystem.bootstrap()` arguments to a `MultiplexLogHandler`.
## Getting Started
### Adding the dependency
`SwiftLogVariadicBootstrap` is designed for Swift 5. To use the handler, you need to declare your dependency in your `Package.swift`:
```swift
.package(url: "https://github.com/ericlewis/swift-log-variadic-bootstrap.git", from: "1.0.0"),
```and to your application/library target, add `"VariadicBootstrap"` to your `dependencies`, e.g. like this:
```swift
.target(name: "BestExampleApp", dependencies: [
.product(name: "VariadicBootstrap", package: "swift-log-variadic-bootstrap")
],
```### Example
It works exactly like [the existing bootstrap function](https://github.com/apple/swift-log#default-logger-behavior)
but it is variadic!#### Allow the labels to be passed in via bootstrap
```swift
import Logging
import VariadicBootstrap
import ExampleLogBackend1
import ExampleLogBackend2LoggingSystem.bootstrap(ExampleLogBackend1.init, ExampleLogBackend2.init)
```
#### Set custom labels per backend
```swift
import Logging
import VariadicBootstrap
import ExampleLogBackend1
import ExampleLogBackend2let backend1 = ExampleLogBackend1(label: "FirstBackend")
let backend2 = ExampleLogBackend2(label: "SecondBackend")LoggingSystem.bootstrap(backend1, backend2)
```
## License
This library is released under the MIT license. See [LICENSE](LICENSE.md) for details.