diff --git a/app/src/main/java/com/example/medilightv2android/services/labdb/LabdbClient.kt b/app/src/main/java/com/example/medilightv2android/services/labdb/LabdbClient.kt index 7a48b70..bb4035b 100644 --- a/app/src/main/java/com/example/medilightv2android/services/labdb/LabdbClient.kt +++ b/app/src/main/java/com/example/medilightv2android/services/labdb/LabdbClient.kt @@ -2,6 +2,7 @@ package com.example.medilightv2android.services.labdb import android.content.Context import android.os.Build +import android.util.Log import com.example.medilightv2android.ble.BleManager import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -43,6 +44,7 @@ data class UploadResult( * 모든 메서드는 suspend, IO 디스패처에서 실행. */ object LabdbClient { + private const val TAG = "LabdbClient" private const val BASE = "https://labdb.medithings.net/api/v1" private const val APP_NAME = "VesiScan" private val JSON = "application/json; charset=utf-8".toMediaType() @@ -66,6 +68,7 @@ object LabdbClient { ble.serialNumber.value.takeIf { it.isNotEmpty() }?.let { put("serialNumber", it) } put("appVersion", appVersion) } + Log.d(TAG, ">> POST /devices/register payload=$body") val req = Request.Builder() .url("$BASE/devices/register") .post(body.toString().toRequestBody(JSON)) @@ -157,10 +160,12 @@ object LabdbClient { return try { client.newCall(req).execute().use { res -> val raw = res.body?.string().orEmpty() + Log.d(TAG, "<< ${req.method} ${req.url.encodedPath} → HTTP ${res.code} body=${raw.take(500)}") val obj = if (raw.isBlank()) JSONObject() else runCatching { JSONObject(raw) }.getOrElse { JSONObject() } res.code to obj } } catch (t: IOException) { + Log.w(TAG, "exec failed: ${req.method} ${req.url}", t) throw LabdbNetworkError(t) } }