Skip to content

Commit 2b1087e

Browse files
committed
add network debug logs [#85]
1 parent 0e43198 commit 2b1087e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

external/src/main/java/com/foke/together/external/camera/external/interceptor/BaseUrlInterceptor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class BaseUrlInterceptor: Interceptor {
1919

2020
fun setBaseUrl(newBaseUrl: String) {
2121
baseUrl = newBaseUrl
22+
if (AppPolicy.isDebugMode) {
23+
AppLog.i(TAG, "setBaseUrl", "set to: $newBaseUrl")
24+
}
2225
try {
2326
val sep = newBaseUrl.indexOf("://")
2427
scheme = newBaseUrl.substring(0, sep)

util/src/main/java/com/foke/together/util/retrofit/NetworkCall.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.foke.together.util.retrofit
33
import com.foke.together.util.AppLog
44
import com.foke.together.util.AppPolicy
55
import okhttp3.Request
6+
import okhttp3.ResponseBody
67
import okio.IOException
78
import okio.Timeout
89
import retrofit2.Call
@@ -17,6 +18,14 @@ class NetworkCall<T>(
1718
override fun onResponse(call: Call<T>, response: Response<T>) {
1819
if (AppPolicy.isDebugMode) {
1920
AppLog.e(TAG, "onResponse", "success: $response")
21+
AppLog.e(TAG, "onResponse", "success: ${response.headers()}")
22+
23+
val body = response.body() as ResponseBody
24+
AppLog.e(TAG, "onResponse", "success: ${response.body()}")
25+
AppLog.e(TAG, "onResponse", "success: ${body.source()}")
26+
AppLog.e(TAG, "onResponse", "success: ${body.contentLength()}")
27+
AppLog.e(TAG, "onResponse", "success: ${body.contentType()}")
28+
AppLog.e(TAG, "onResponse", "success: ${body.bytes()}")
2029
}
2130

2231
if (response.isSuccessful) {

0 commit comments

Comments
 (0)