chore(bugcollect): 清理调试日志,准备发布正式版本
这个提交包含在:
父节点
84c9eb5e7a
当前提交
ffafd94a1e
@ -88,12 +88,10 @@ object BugCollect {
|
|||||||
)
|
)
|
||||||
if (!isReady()) {
|
if (!isReady()) {
|
||||||
synchronized(pendingErrorsLock) { pendingErrors.add(event) }
|
synchronized(pendingErrorsLock) { pendingErrors.add(event) }
|
||||||
android.util.Log.d("BugCollect", "captureError: SDK not ready, queued (${pendingErrors.size} pending)")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
flushPendingErrors()
|
flushPendingErrors()
|
||||||
queue().push(event)
|
queue().push(event)
|
||||||
android.util.Log.d("BugCollect", "captureError: pushed to queue")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun captureCrash(error: Throwable, tags: Map<String, Any?> = emptyMap()) {
|
fun captureCrash(error: Throwable, tags: Map<String, Any?> = emptyMap()) {
|
||||||
@ -154,7 +152,6 @@ object BugCollect {
|
|||||||
if (crashCaptureStarted) return
|
if (crashCaptureStarted) return
|
||||||
if (!XuqmSDK.isInitialized()) return
|
if (!XuqmSDK.isInitialized()) return
|
||||||
crashCaptureStarted = true
|
crashCaptureStarted = true
|
||||||
android.util.Log.w("BugCollect", "startCrashCapture: registering crash handler")
|
|
||||||
CrashCapture.start(
|
CrashCapture.start(
|
||||||
appContext = XuqmSDK.appContext,
|
appContext = XuqmSDK.appContext,
|
||||||
appKey = XuqmSDK.appKey,
|
appKey = XuqmSDK.appKey,
|
||||||
@ -183,7 +180,6 @@ object BugCollect {
|
|||||||
pendingErrors.clear()
|
pendingErrors.clear()
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
android.util.Log.d("BugCollect", "flushPendingErrors: ${events.size} events")
|
|
||||||
events.forEach { queue().push(it) }
|
events.forEach { queue().push(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -111,10 +111,7 @@ internal class LogQueue(
|
|||||||
|
|
||||||
private fun flush() {
|
private fun flush() {
|
||||||
// URL 未就绪时跳过,等下次定时 flush
|
// URL 未就绪时跳过,等下次定时 flush
|
||||||
if (logApiUrl.isBlank()) {
|
if (logApiUrl.isBlank()) return
|
||||||
Log.d(TAG, "flush: URL blank, skipping")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val issues: List<IssueEvent>
|
val issues: List<IssueEvent>
|
||||||
val events: List<LogEvent>
|
val events: List<LogEvent>
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
@ -124,7 +121,6 @@ internal class LogQueue(
|
|||||||
pendingIssues.clear()
|
pendingIssues.clear()
|
||||||
pendingEvents.clear()
|
pendingEvents.clear()
|
||||||
}
|
}
|
||||||
Log.d(TAG, "flush: uploading ${issues.size} issues, ${events.size} events, url=$logApiUrl")
|
|
||||||
if (issues.isNotEmpty()) {
|
if (issues.isNotEmpty()) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
runCatching { LogUploader.uploadIssues(logApiUrl, issues) }
|
runCatching { LogUploader.uploadIssues(logApiUrl, issues) }
|
||||||
|
|||||||
@ -38,7 +38,6 @@ internal object LogUploader {
|
|||||||
fun uploadIssues(logApiUrl: String, issues: List<IssueEvent>) {
|
fun uploadIssues(logApiUrl: String, issues: List<IssueEvent>) {
|
||||||
if (issues.isEmpty()) return
|
if (issues.isEmpty()) return
|
||||||
val url = "${resolveUrl(logApiUrl)}/bugcollect/v1/issues/batch"
|
val url = "${resolveUrl(logApiUrl)}/bugcollect/v1/issues/batch"
|
||||||
Log.w(TAG, "uploadIssues: url=$url, count=${issues.size}, thread=${Thread.currentThread().name}")
|
|
||||||
val envelope = createEnvelope()
|
val envelope = createEnvelope()
|
||||||
val events = JSONArray()
|
val events = JSONArray()
|
||||||
for (issue in issues) {
|
for (issue in issues) {
|
||||||
@ -79,17 +78,14 @@ internal object LogUploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun post(url: String, body: String) {
|
private fun post(url: String, body: String) {
|
||||||
android.util.Log.w(TAG, "POST_START url=$url bodyLen=${body.length}")
|
|
||||||
val request = Request.Builder()
|
val request = Request.Builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.post(body.toRequestBody(JSON_MEDIA))
|
.post(body.toRequestBody(JSON_MEDIA))
|
||||||
.build()
|
.build()
|
||||||
try {
|
client.newCall(request).execute().use { response ->
|
||||||
val response = client.newCall(request).execute()
|
if (!response.isSuccessful) {
|
||||||
android.util.Log.w(TAG, "POST_DONE code=${response.code} url=$url")
|
Log.w(TAG, "Upload failed: HTTP ${response.code} url=$url")
|
||||||
response.close()
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
android.util.Log.e(TAG, "POST_FAIL url=$url", e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户