Skip to content

Commit d458492

Browse files
committed
Improve debugging of RESPValue
Motivation: Reading output from `RESPValue` existentials is entirely verbose and does not provide a human-readable description of what is being represented. Modifications: - Add conformance to `CustomStringConvertible` for `RESPValue` - Remove redundant logging of arguments in `RedisConnection.send` Result: String representations of `RESPValue` should now be more readable for human to understand.
1 parent d484858 commit d458492

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Sources/RedisNIO/RESP/RESPValue.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ extension RESPValue: ExpressibleByIntegerLiteral {
8181
}
8282
}
8383

84+
// MARK: Custom String Convertible
85+
86+
extension RESPValue: CustomStringConvertible {
87+
public var description: String {
88+
switch self {
89+
case .integer, .simpleString, .bulkString: return self.string!
90+
case .null: return "NULL"
91+
case let .array(elements): return "[\(elements.map({ $0.description }).joined(separator: ","))]"
92+
case let .error(e): return e.message
93+
default: return ""
94+
}
95+
}
96+
}
97+
8498
// MARK: Computed Values
8599

86100
extension RESPValue {

Sources/RedisNIO/RedisClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public final class RedisConnection: RedisClient {
176176
guard case let .failure(error) = result else { return }
177177
self.logger.error("\(error.localizedDescription)")
178178
}
179-
logger.debug("Sending command \"\(command)\" with \(arguments) encoded as \(args)")
179+
logger.debug("Sending command \"\(command)\" with \(arguments)")
180180

181181
guard sendCommandsImmediately else {
182182
return channel.write(context).flatMap { promise.futureResult }

0 commit comments

Comments
 (0)