-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging contains newlines (because it uses ByteBuffer.debugDescription which IMHO it shouldn't) #690
Comments
Much easier once apple/swift-nio#2447 is done (e.g. by getting apple/swift-nio#2475 in) |
Happy to clean this up as well once I'm done with apple/swift-nio#2475. |
@weissi, okay, here's the plan:
|
Works for me assuming you mark it as "Work in Progress" PR such that the PR won't accidentally get merged ;) |
Okay! I looked around in the code, and it's not immediately obvious where the buffer gets logged. If you have a hint on where to look — now is the time. My next step is to put together a minimal project that uses AHC so I can debug it stumble at the code that outputs the request/response bytes. Once I find where it is, it should be straightforward to swap out what/how it gets logged. |
I think it is coming from here: async-http-client/Sources/AsyncHTTPClient/ConnectionPool/HTTP1/HTTP1ClientChannelHandler.swift Lines 117 to 119 in e1c85a6
|
What I learned today is that the default After that discovery I think we should rethink the |
Yep! @dnadoba
That's what I found, too — assumed that httpPart is some struct / class that wraps or has a
Since there is no code that handles specific logging output of a The big question is whether AHC or anything else should use Option A: Rework @weissi, should we consider something like this in func debugDescription(format: HexDumpFormat = .debug) -> String {
return self.hexDump(format: format)
} And then add additional format (let's say there will be Additionally, we could remove Option B: Rework AHC logging to not use That would probably be around the part that @dnadoba highlighted: self.logger.trace("HTTP response part received", metadata: [
"ahc-http-part": "\(httpPart)",
]) We'll need to cast httpPart to something we can grab the self.logger.trace("HTTP response part received", metadata: [
"ahc-http-bytes": "\((httpPart as? WhateverHasTheByteBuffer).bytes?.hexDump(format: .xxdCompatible))",
]) |
We need to fix |
Afterwards we no longer have new lines in the output and we need to think about #689 and decided if the full contents of a request/response should actually be included in the trace log or not. We can close this issue then and shift the discussion over to #689. @natikgadzhi sorry for kind of taking over this issue. I have discovered this issue in related work over in swift-certificates and as this is against the documented behaviour I though this might be a controversial PR. |
All good! Thank you for keeping the discussion in the open, so I can follow along. Good to close this, I'll keep an eye on the follow up issues. |
AHC logs bytes of the HTTP connection (which is in itself questionable #689). But even if we think that's okay I don't think it should just log
ByteBuffer.debugDescription
which contains newlines and is supposed to be human readable.If AHC thinks it needs to log the bytes then it should do so without logging all the other crap that ByteBuffer.debugDescription contains (especially the newlines, don't think we usually want to have newlines in our log metadata?).
The text was updated successfully, but these errors were encountered: