-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
KTOR-7806 Add logging with standard Okhttp-like format #4592
Conversation
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
...-client-plugins/ktor-client-logging/jvm/test/io/ktor/client/plugins/logging/NewFormatTest.kt
Outdated
Show resolved
Hide resolved
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
is OutgoingContent.ContentWrapper -> calcRequestBodySize(content.delegate(), content.headers) | ||
is OutgoingContent.NoContent -> 0 | ||
is OutgoingContent.ProtocolUpgrade -> 0 | ||
else -> error("Unable to calculate the size for type ${content::class.simpleName}") |
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.
Could you tell me if the exception is supposed to be handled or printed?
I would return null
and handle this case explicitly
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.
It's more like a guard. If the exception is thrown, then it's a bug.
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.
Please add the test to make sure the exception is not lost
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.
As I said before, the exception will be raised only if there is a bug in the code (like an assert). I don't understand what I should test.
@@ -239,6 +613,34 @@ public val Logging: ClientPlugin<LoggingConfig> = createClientPlugin("Logging", | |||
ResponseObserver.install(ResponseObserver.prepare { onResponse(observer) }, client) | |||
} | |||
|
|||
private fun Url.pathQuery(): String { | |||
return buildString { |
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.
Please consider adding:
- a non-empty browser test with
window.location
- test with default request plugin and relative path
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.
test with default request plugin and relative path
Wouldn't I test the DefaultRequest
plugin then? If not, can you explain the subject under test?
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.
a non-empty browser test with window.location
Can you explain in more detail how the test should look like?
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.
Set window.location.href = "https://ktor.io"
So this call will give you a different result:
private fun locationOrigin(): String = js( |
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.
Set
window.location.href = "https://ktor.io"
So this call will give you a different result:
private fun locationOrigin(): String = js(
This method is used only within the URLBuilder.Companion.origin
property, which I don't use at all.
7e617f8
to
06034f5
Compare
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
is OutgoingContent.ContentWrapper -> calcRequestBodySize(content.delegate(), content.headers) | ||
is OutgoingContent.NoContent -> 0 | ||
is OutgoingContent.ProtocolUpgrade -> 0 | ||
else -> error("Unable to calculate the size for type ${content::class.simpleName}") |
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.
Please add the test to make sure the exception is not lost
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
06034f5
to
bd1cd22
Compare
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Show resolved
Hide resolved
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Outdated
Show resolved
Hide resolved
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.
lgtm
...ktor-client-plugins/ktor-client-logging/common/src/io/ktor/client/plugins/logging/Logging.kt
Show resolved
Hide resolved
@@ -165,6 +514,23 @@ public val Logging: ClientPlugin<LoggingConfig> = createClientPlugin("Logging", | |||
return@on | |||
} | |||
|
|||
if (okHttpFormat) { |
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.
it would be nice to have extensions for okHttp format grouped in a separate file
4ac86cf
to
c1e0689
Compare
https://youtrack.jetbrains.com/issue/KTOR-7806