-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Disable content logging by default #7633
Disable content logging by default #7633
Conversation
|
||
public static readonly LoggingPolicy Shared = new LoggingPolicy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth having SharedNoContent
and SharedWithContent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it would have more parameters pretty soon
@@ -92,19 +98,19 @@ private static async Task ProcessAsync(HttpPipelineMessage message, ReadOnlyMemo | |||
|
|||
var textResponse = ContentTypeUtilities.TryGetTextEncoding(message.Response.Headers.ContentType, out Encoding? responseTextEncoding); | |||
|
|||
bool wrapResponseStream = message.Response.ContentStream != null && message.Response.ContentStream?.CanSeek == false && s_eventSource.ShouldLogContent(isError); | |||
bool logResponseContent = _logContent && message.Response.ContentStream != null; | |||
bool wrapResponseContent = logResponseContent && message.Response.ContentStream?.CanSeek == false && s_eventSource.ShouldLogContent(isError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check the generated IL, but at least when targeting net45 my old code base had to change a lot of this syntax not to use the Elvis operator when comparing against value types. It causes extra allocations. Just separate check if ContentStream != null
prior.
In a frequent code path, this could add up (it did in our case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked, the Elvis doesn't result in allocation and produces almost identical IL and asm
Fixes: #7559