From 466a7ed384367f62f7dc0ad13576d8f684648fd2 Mon Sep 17 00:00:00 2001 From: tomer doron Date: Thu, 17 Jan 2019 13:38:53 -0800 Subject: [PATCH] fix compilation on 4.2 (#31) motivation: recent change for 5.x broken 4.x changes: add code branch for swift < 5 --- Sources/Logging/Logging.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/Logging/Logging.swift b/Sources/Logging/Logging.swift index d07a079..0149c5a 100644 --- a/Sources/Logging/Logging.swift +++ b/Sources/Logging/Logging.swift @@ -142,7 +142,7 @@ extension Logging.Level: Comparable { // Then we could write it as follows and it would work under Swift 5 and not only 4 as it does currently: // extension Logging.Metadata.Value: Equatable { extension Logging.MetadataValue: Equatable { - public static func ==(lhs: Logging.Metadata.Value, rhs: Logging.Metadata.Value) -> Bool { + public static func == (lhs: Logging.Metadata.Value, rhs: Logging.Metadata.Value) -> Bool { switch (lhs, rhs) { case (.string(let lhs), .string(let rhs)): return lhs == rhs @@ -154,7 +154,6 @@ extension Logging.MetadataValue: Equatable { return false } } - } /// Ships with the logging module, used to multiplex to multiple logging handlers @@ -287,6 +286,7 @@ internal struct StdoutLogger: LogHandler { }?.0 ?? "\(timestamp)" } } + // Extension has to be done on explicit type rather than Logging.Metadata.Value as workaround for: https://bugs.swift.org/browse/SR-9687 extension Logging.MetadataValue: ExpressibleByStringLiteral { public typealias StringLiteralType = String @@ -316,10 +316,9 @@ extension Logging.MetadataValue: ExpressibleByStringInterpolation { self = .string(strings.map { $0.description }.reduce("", +)) } - // TODO: seems not to exist on 5.0-DEVELOPMENT-SNAPSHOT-2019-01-16-a - // public init(stringInterpolationSegment expr: T) { - // self = .string(String(stringInterpolationSegment: expr)) - // } + public init(stringInterpolationSegment expr: T) { + self = .string(String(stringInterpolationSegment: expr)) + } #endif }