Skip to content

Commit

Permalink
fix size grpc log
Browse files Browse the repository at this point in the history
  • Loading branch information
kernel0x committed Mar 18, 2024
1 parent 062d8a3 commit cd6abad
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ Pick a UI implementation and add the dependency:

````java
dependencies {
debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.8'
releaseImplementation 'com.github.kernel0x.finch:noop:2.2.8'
debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.9'
releaseImplementation 'com.github.kernel0x.finch:noop:2.2.9'
// optional only for OkHttp
debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.8'
releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.8'
debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.9'
releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.9'
// optional only for GRPC
debugImplementation 'com.github.kernel0x.finch:log-grpc:2.2.8'
releaseImplementation 'com.github.kernel0x.finch:log-grpc-noop:2.2.8'
debugImplementation 'com.github.kernel0x.finch:log-grpc:2.2.9'
releaseImplementation 'com.github.kernel0x.finch:log-grpc-noop:2.2.9'
// optional only for logs
debugImplementation 'com.github.kernel0x.finch:log:2.2.8'
releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.8'
debugImplementation 'com.github.kernel0x.finch:log:2.2.9'
releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.9'
}
````

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ data class NetworkLogEntity(
}
}

fun getDurationString(): String? {
fun getDurationString(): String {
return "$duration ms"
}

fun getRequestSizeString(): String {
return formatBytes(requestContentLength)
}

fun getResponseSizeString(): String? {
fun getResponseSizeString(): String {
return formatBytes(responseContentLength)
}

Expand All @@ -135,15 +135,15 @@ data class NetworkLogEntity(
}

fun isSsl(): Boolean {
return scheme.toLowerCase(Locale.getDefault()) == "https"
return scheme.lowercase(Locale.getDefault()) == "https"
}

private fun formatBody(body: String, contentType: String?): String {
return if (contentType != null && contentType.toLowerCase(Locale.getDefault())
return if (contentType != null && contentType.lowercase(Locale.getDefault())
.contains("json")
) {
FormatUtil.formatJson(body)
} else if (contentType != null && contentType.toLowerCase(Locale.getDefault())
} else if (contentType != null && contentType.lowercase(Locale.getDefault())
.contains("xml")
) {
FormatUtil.formatXml(body)
Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext.versions = [
minSdk : 21,
targetSdk : 34,
compileSdk : 34,
libraryVersion : '2.2.8',
libraryVersion : '2.2.9',
libraryVersionCode: 15,

okhttp3 : '3.7.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ internal class FinchClientInterceptor : ClientInterceptor {
TextFormat.printer().escapingNonAscii(false).printToString(
message as MessageOrBuilder
)
networkLog.responseContentLength =
networkLog.responseBody.toByteArray().size.toLong()
FinchGrpcLogger.logNetworkEvent(networkLog)
super.onMessage(message)
}
Expand Down Expand Up @@ -89,6 +91,8 @@ internal class FinchClientInterceptor : ClientInterceptor {
networkLog.requestBody = TextFormat.printer().escapingNonAscii(false).printToString(
message as MessageOrBuilder
)
networkLog.requestContentLength =
networkLog.requestBody.toByteArray().size.toLong()
FinchGrpcLogger.logNetworkEvent(networkLog)
super.sendMessage(message)
}
Expand Down
12 changes: 6 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ android {
}

dependencies {
//debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.8'
//releaseImplementation 'com.github.kernel0x.finch:noop:2.2.8'
//debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.8'
//releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.8'
//debugImplementation 'com.github.kernel0x.finch:log:2.2.8'
//releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.8'
//debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.9'
//releaseImplementation 'com.github.kernel0x.finch:noop:2.2.9'
//debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.9'
//releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.9'
//debugImplementation 'com.github.kernel0x.finch:log:2.2.9'
//releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.9'
debugImplementation project(":ui-drawer")
debugImplementation project(":log")
debugImplementation project(":log-okhttp")
Expand Down

0 comments on commit cd6abad

Please sign in to comment.