From b7475a3b6f142cdc7735da7361b8da68154c93cc Mon Sep 17 00:00:00 2001 From: jjangddu Date: Mon, 1 Jun 2026 14:41:27 +0900 Subject: [PATCH] =?UTF-8?q?Labdb:=20debug=20logging=20=E2=80=94=20register?= =?UTF-8?q?=20payload=20+=20HTTP=20=EC=9D=91=EB=8B=B5=20body=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit INTERNAL_ERROR(500) 원인 좁히기 위해 LabdbClient에 logcat 추가: - POST /devices/register 보내는 정확한 payload (TAG=LabdbClient) - 모든 응답의 HTTP code + raw body (앞 500자) - IOException 발생 시 스택 trace logcat 필터: tag:LabdbClient Co-Authored-By: Claude Opus 4.7 (1M context) --- .../example/medilightv2android/services/labdb/LabdbClient.kt | 5 +++++ 1 file changed, 5 insertions(+) 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) } }