mirror of
https://github.com/apple/swift-log
synced 2026-11-27 04:14:20 +00:00
fix compilation on 4.2 (#31)
motivation: recent change for 5.x broken 4.x changes: add code branch for swift < 5
This commit is contained in:
1 parent
11ea26a505
commit
466a7ed384
1 file changed
+5
-6
@@ -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<T>(stringInterpolationSegment expr: T) {
|
||||
// self = .string(String(stringInterpolationSegment: expr))
|
||||
// }
|
||||
public init<T>(stringInterpolationSegment expr: T) {
|
||||
self = .string(String(stringInterpolationSegment: expr))
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user