This code is for debug build (see the path), so no need to check again
This commit is contained in:
parent
f3bc39a0c5
commit
28bfea6af0
|
@ -38,31 +38,28 @@ class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
|
||||||
*/
|
*/
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun log(@NonNull message: String) {
|
override fun log(@NonNull message: String) {
|
||||||
// In RELEASE there is no log, but for sure, test again BuildConfig.DEBUG
|
Timber.v(message)
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Timber.v(message)
|
|
||||||
|
|
||||||
if (message.startsWith("{")) {
|
if (message.startsWith("{")) {
|
||||||
// JSON Detected
|
// JSON Detected
|
||||||
try {
|
try {
|
||||||
val o = JSONObject(message)
|
val o = JSONObject(message)
|
||||||
logJson(o.toString(INDENT_SPACE))
|
logJson(o.toString(INDENT_SPACE))
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
// Finally this is not a JSON string...
|
// Finally this is not a JSON string...
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
}
|
}
|
||||||
} else if (message.startsWith("[")) {
|
} else if (message.startsWith("[")) {
|
||||||
// JSON Array detected
|
// JSON Array detected
|
||||||
try {
|
try {
|
||||||
val o = JSONArray(message)
|
val o = JSONArray(message)
|
||||||
logJson(o.toString(INDENT_SPACE))
|
logJson(o.toString(INDENT_SPACE))
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
// Finally not JSON...
|
// Finally not JSON...
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Else not a json string to log
|
|
||||||
}
|
}
|
||||||
|
// Else not a json string to log
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logJson(formattedJson: String) {
|
private fun logJson(formattedJson: String) {
|
||||||
|
|
Loading…
Reference in New Issue