Skip to content

Commit 08ec50d

Browse files
authored
Add SwiftLogNoOpLogHandler.init(_: String) (apple#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() }) ```
1 parent 3577a99 commit 08ec50d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sources/Logging/Logging.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,8 @@ public struct StreamLogHandler: LogHandler {
11471147
public struct SwiftLogNoOpLogHandler: LogHandler {
11481148
public init() {}
11491149

1150+
public init(_: String) {}
1151+
11501152
@inlinable public func log(level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata?, file: String, function: String, line: UInt) {}
11511153

11521154
@inlinable public subscript(metadataKey _: String) -> Logger.Metadata.Value? {

0 commit comments

Comments
 (0)