Skip to content

Commit

Permalink
add network debug logs [FoKE-Developers#85]
Browse files Browse the repository at this point in the history
  • Loading branch information
DokySp committed Oct 11, 2024
1 parent 0e43198 commit 9ef5117
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class BaseUrlInterceptor: Interceptor {

fun setBaseUrl(newBaseUrl: String) {
baseUrl = newBaseUrl
if (AppPolicy.isDebugMode) {
AppLog.i(TAG, "setBaseUrl", "set to: $newBaseUrl")
}
try {
val sep = newBaseUrl.indexOf("://")
scheme = newBaseUrl.substring(0, sep)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.foke.together.util.retrofit
import com.foke.together.util.AppLog
import com.foke.together.util.AppPolicy
import okhttp3.Request
import okhttp3.ResponseBody
import okio.IOException
import okio.Timeout
import retrofit2.Call
Expand All @@ -17,6 +18,14 @@ class NetworkCall<T>(
override fun onResponse(call: Call<T>, response: Response<T>) {
if (AppPolicy.isDebugMode) {
AppLog.e(TAG, "onResponse", "success: $response")
AppLog.e(TAG, "onResponse", "success: ${response.headers()}")

val body = response.body() as ResponseBody
AppLog.e(TAG, "onResponse", "success: ${response.body()}")
AppLog.e(TAG, "onResponse", "success: ${body.source()}")
AppLog.e(TAG, "onResponse", "success: ${body.contentLength()}")
AppLog.e(TAG, "onResponse", "success: ${body.contentType()}")
AppLog.e(TAG, "onResponse", "success: ${body.bytes()}")
}

if (response.isSuccessful) {
Expand Down

0 comments on commit 9ef5117

Please sign in to comment.