Skip to content

Commit 4a989a4

Browse files
committed
Improve HTTPClient logcat consistency
Added "Got Response =" to the beginning of each line were we got a response. This exact wording was picked since it is the same number of characters as "Request Sent = ", this way it lines up in the logs, making them easier to read.
1 parent 8dca91f commit 4a989a4

File tree

1 file changed

+6
-6
lines changed
  • OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl

1 file changed

+6
-6
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/http/impl/HttpClient.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ internal class HttpClient(
197197
PreferenceStores.ONESIGNAL,
198198
PreferenceOneSignalKeys.PREFS_OS_HTTP_CACHE_PREFIX + cacheKey,
199199
)
200-
Logging.debug("HttpClient: ${method ?: "GET"} $url - Using Cached response due to 304: " + cachedResponse)
200+
Logging.debug("HttpClient: Got Response = ${method ?: "GET"} ${con.url} - Using Cached response due to 304: " + cachedResponse)
201201

202202
// TODO: SHOULD RETURN OK INSTEAD OF NOT_MODIFIED TO MAKE TRANSPARENT?
203203
retVal = HttpResponse(httpResponse, cachedResponse, retryAfterSeconds = retryAfter)
@@ -207,12 +207,12 @@ internal class HttpClient(
207207
val scanner = Scanner(inputStream, "UTF-8")
208208
val json = if (scanner.useDelimiter("\\A").hasNext()) scanner.next() else ""
209209
scanner.close()
210-
Logging.debug("HttpClient: ${method ?: "GET"} $url - STATUS: $httpResponse JSON: " + json)
210+
Logging.debug("HttpClient: Got Response = ${method ?: "GET"} ${con.url} - STATUS: $httpResponse - Body: " + json)
211211

212212
if (cacheKey != null) {
213213
val eTag = con.getHeaderField("etag")
214214
if (eTag != null) {
215-
Logging.debug("HttpClient: Response has etag of $eTag so caching the response.")
215+
Logging.debug("HttpClient: Got Response = Response has etag of $eTag so caching the response.")
216216

217217
_prefs.saveString(
218218
PreferenceStores.ONESIGNAL,
@@ -230,7 +230,7 @@ internal class HttpClient(
230230
retVal = HttpResponse(httpResponse, json, retryAfterSeconds = retryAfter)
231231
}
232232
else -> {
233-
Logging.debug("HttpClient: ${method ?: "GET"} $url - FAILED STATUS: $httpResponse")
233+
Logging.debug("HttpClient: Got Response = ${method ?: "GET"} ${con.url} - FAILED STATUS: $httpResponse")
234234

235235
var inputStream = con.errorStream
236236
if (inputStream == null) {
@@ -243,9 +243,9 @@ internal class HttpClient(
243243
jsonResponse =
244244
if (scanner.useDelimiter("\\A").hasNext()) scanner.next() else ""
245245
scanner.close()
246-
Logging.warn("HttpClient: $method RECEIVED JSON: $jsonResponse")
246+
Logging.warn("HttpClient: Got Response = $method - STATUS: $httpResponse - Body: $jsonResponse")
247247
} else {
248-
Logging.warn("HttpClient: $method HTTP Code: $httpResponse No response body!")
248+
Logging.warn("HttpClient: Got Response = $method - STATUS: $httpResponse - No response body!")
249249
}
250250

251251
retVal = HttpResponse(httpResponse, jsonResponse, retryAfterSeconds = retryAfter)

0 commit comments

Comments
 (0)