session-ios/SignalUtilitiesKit/Dictionary+Description.swift

14 lines
536 B
Swift
Raw Normal View History

2020-11-11 00:58:56 +01:00
public extension Dictionary {
public var prettifiedDescription: String {
return "[ " + map { key, value in
let keyDescription = String(describing: key)
let valueDescription = String(describing: value)
let maxLength = 20
let truncatedValueDescription = valueDescription.count > maxLength ? valueDescription.prefix(maxLength) + "..." : valueDescription
return keyDescription + " : " + truncatedValueDescription
}.joined(separator: ", ") + " ]"
}
}