mirror of
https://github.com/apple/swift-log
synced 2026-11-24 03:47:49 +00:00
Add SwiftLogNoOpLogHandler.init(_: String) (#194)
Motivation:
`LogHandler` facotories are given a label as input and return a
`LogHandler`. Since the no-op handler doesn't care about the label
callers must provide a thunk: `{ _ in SwiftLogNoOpLogHandler() }`.
That's fine but slightly more annoying to type than it needs to be.
Modifications:
- Add `SwiftLogNoOpLogHandler.init(_: String)`
Result:
Users can create a logger with the no-op handler with:
```swift
Logger(label: "foo", factory: SwiftLogNoOpLogHandler.init)
```
instead of:
```swift
Logger(label: "foo", factory: { _ in SwiftLogNoOpLogHandler() })
```
This commit is contained in:
1 parent
3577a992d3
commit
08ec50d7b1
1 file changed
+2
@@ -1147,6 +1147,8 @@ public struct StreamLogHandler: LogHandler {
|
||||
public struct SwiftLogNoOpLogHandler: LogHandler {
|
||||
public init() {}
|
||||
|
||||
public init(_: String) {}
|
||||
|
||||
@inlinable public func log(level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata?, file: String, function: String, line: UInt) {}
|
||||
|
||||
@inlinable public subscript(metadataKey _: String) -> Logger.Metadata.Value? {
|
||||
|
||||
Reference in new issue
Block a user