Skip to content

Commit

Permalink
Add debugging info to HTTP2StreamChannel too. (#198)
Browse files Browse the repository at this point in the history
Motivation:

Sometimes folks will want to print things about the HTTP2StreamChannel,
and we should give them the things we can safely get. We also may want a
shorter log for NIOHTTP2Handler as the standard description, with the
wall of text available in the debug description.

Modifications:

- Conform HTTP2StreamChannel to CustomStringConvertible
- Conform NIOHTTP2Handler to CustomDebugStringConvertible.

Result:

Even better debug info.
  • Loading branch information
Lukasa authored May 11, 2020
1 parent cdf3c48 commit b66a08e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/NIOHTTP2/HTTP2ChannelHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ extension HTTP2ConnectionStateMachine.ValidationState {

extension NIOHTTP2Handler: CustomStringConvertible {
public var description: String {
return "NIOHTTP2Handler(mode: \(String(describing: self.mode)))"
}
}


extension NIOHTTP2Handler: CustomDebugStringConvertible {
public var debugDescription: String {
return """
NIOHTTP2Handler(
stateMachine: \(String(describing: self.stateMachine)),
Expand Down
7 changes: 7 additions & 0 deletions Sources/NIOHTTP2/HTTP2StreamChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,13 @@ extension HTTP2StreamChannel {
}
}

// MARK: Custom String Convertible
extension HTTP2StreamChannel {
public var description: String {
return "HTTP2StreamChannel(streamID: \(self.streamID), isActive: \(self.isActive), isWritable: \(self.isWritable))"
}
}

extension HTTP2Frame {
/// A shorthand heuristic for how many bytes we assume a frame consumes on the wire.
///
Expand Down

0 comments on commit b66a08e

Please sign in to comment.