[6.0.0][全量日志] 全量日志添加状态记录,日志中心由【导出全量日志】改为【上传全量日志】
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.zhjt.mogo_core_function_devatools.logcat
|
||||
|
||||
import android.content.*
|
||||
import android.os.Build
|
||||
import android.os.Process
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
@@ -10,6 +11,9 @@ import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.core.log.record.*
|
||||
import com.mogo.core.log.record.config.*
|
||||
import com.mogo.core.log.record.config.crash.*
|
||||
import com.mogo.core.log.record.config.state.IStateProvider
|
||||
import com.mogo.core.log.record.model.UploadError
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.function.api.devatools.logcat.*
|
||||
import com.zhidao.loglib.bean.RemoteLogPushContent
|
||||
import com.zhjt.mogo_core_function_devatools.logcat.config.LogRecordConfig
|
||||
@@ -43,6 +47,62 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
.recordDir(File(context.getExternalFilesDir(null), "logcat"))
|
||||
.pid(Process.myPid())
|
||||
.generateZipDir(zipDir.absolutePath)
|
||||
.stateProvider(object : IStateProvider {
|
||||
override fun provide(divider:String?): Map<String, Any?> {
|
||||
return mutableMapOf<String, Any?>().also { itx ->
|
||||
itx["build_sdk_version"] = Build.VERSION.SDK_INT
|
||||
itx["build_device"] = Build.DEVICE
|
||||
itx["build_host"] = Build.HOST
|
||||
itx["build_id"] = Build.ID
|
||||
itx["build_host"] = Build.HOST
|
||||
itx["build_brand"] = Build.BRAND
|
||||
itx["build_model"] = Build.MODEL
|
||||
itx["build_product"] = Build.PRODUCT
|
||||
itx["build_board"] = Build.BOARD
|
||||
itx["build_bootloader"] = Build.BOOTLOADER
|
||||
itx["${divider}-1"] = divider
|
||||
itx["应用名称"] = AppConfigInfo.appName
|
||||
itx["应用版本名称"] = AppConfigInfo.appVersionName
|
||||
itx["应用版本号"] = AppConfigInfo.appVersionCode
|
||||
itx["渠道"] = AppConfigInfo.flavor
|
||||
itx["GIT分支"] = AppConfigInfo.workingBranchName
|
||||
itx["GIT分支HASH"] = AppConfigInfo.workingBranchHash
|
||||
itx["${divider}-2"] = divider
|
||||
itx["MAP-SDK版本"] = AppConfigInfo.mapSdkVersion
|
||||
itx["MAP-OPT-SDK版本"] = AppConfigInfo.mapSdkOptVersion
|
||||
itx["ADAS-SDK版本"] = AppConfigInfo.adasSdkVersion
|
||||
itx["${divider}-3"] = divider
|
||||
itx["OBU-SDk版本"] = AppConfigInfo.obuSdkVersion
|
||||
itx["OBU-INFO"] = AppConfigInfo.obuInfo
|
||||
itx["${divider}-4"] = divider
|
||||
itx["数字版权ID"] = AppConfigInfo.widevineIDMd5
|
||||
itx["设备唯一标识"] = AppConfigInfo.uniqueDeviceId
|
||||
itx["中台分配的SN"] = AppConfigInfo.mogoSN
|
||||
itx["中台分配的令牌"] = AppConfigInfo.mogoToken
|
||||
itx["当前网络连接模式"] = AppConfigInfo.netMode
|
||||
itx["网络是否正常"] = AppConfigInfo.isConnectNet
|
||||
itx["Socket是否正常"] = AppConfigInfo.isConnectSocket
|
||||
itx["ADAS连接是否正常"] = AppConfigInfo.isConnectAutopilot
|
||||
itx["OBU连接是否正常"] = AppConfigInfo.isConnectObu
|
||||
itx["连接工控机状态描述"] = AppConfigInfo.connectStatusDescribe
|
||||
itx["${divider}-5"] = divider
|
||||
itx["是否司机端"] = AppConfigInfo.isDriver
|
||||
itx["是否是乘客端"] = !AppConfigInfo.isDriver
|
||||
if (!AppConfigInfo.isDriver) {
|
||||
itx["当前车机是乘客屏,对应的司机屏SN"] = AppConfigInfo.serverSn
|
||||
}
|
||||
itx["司乘屏连接状态"] = AppConfigInfo.isConnectedNetty
|
||||
itx["${divider}-6"] = divider
|
||||
itx["车牌号"] = AppConfigInfo.plateNumber
|
||||
itx["mac"] = AppConfigInfo.iPCMacAddress
|
||||
itx["docker版本"] = AppConfigInfo.dockerVersion
|
||||
itx["协议版本号"] = AppConfigInfo.protocolVersionNumber
|
||||
itx["${divider}-7"] = divider
|
||||
itx["角色"] = AppConfigInfo.role
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
.crashConfig(CrashConfig.Builder()
|
||||
.enabled(true)
|
||||
.crashDir(File(context.getExternalFilesDir(null), "logcat/crash"))
|
||||
@@ -119,6 +179,13 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
return LogcatManager.export()
|
||||
}
|
||||
|
||||
override fun upload(): Unit = runBlocking {
|
||||
val state = LogcatManager.upload(0, System.currentTimeMillis())
|
||||
if (state is UploadError) {
|
||||
throw AssertionError(state.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun testJavaCrash(runOnNewThread: Boolean) {
|
||||
LogcatManager.testJavaCrash(runOnNewThread)
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import com.zhidao.cosupload.callback.CosStatusCallback
|
||||
import com.zhidao.cosupload.callback.CosStatusCallbackManager
|
||||
import com.zhidao.cosupload.model.CallbackData
|
||||
import com.zhidao.loglib.upload.UploadManager
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.flow.channelFlow
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
|
||||
internal class LogRecordUploader : ILogcatUploader {
|
||||
@@ -20,10 +21,10 @@ internal class LogRecordUploader : ILogcatUploader {
|
||||
private const val TAG = "LogRecordUploader"
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override suspend fun upload(startTime: Long, endTime: Long, generatedZipPath: String): UploadState =
|
||||
channelFlow {
|
||||
flow {
|
||||
Log.d(TAG, "---- 开始上传 --- 1 ---")
|
||||
val channel = Channel<UploadState>()
|
||||
CosStatusCallbackManager.getInstance().register(object : CosStatusCallback {
|
||||
|
||||
override fun onStartUpload(data: CallbackData?) {
|
||||
@@ -35,7 +36,7 @@ internal class LogRecordUploader : ILogcatUploader {
|
||||
override fun uploadCosCompleted(data: CallbackData?) {
|
||||
if (data?.localPath == generatedZipPath) {
|
||||
Log.d(TAG, "---- uploadCosCompleted ---: $data")
|
||||
trySend(UploadSuccess)
|
||||
channel.trySend(UploadSuccess)
|
||||
CosStatusCallbackManager.getInstance().unregister(this)
|
||||
}
|
||||
}
|
||||
@@ -43,7 +44,7 @@ internal class LogRecordUploader : ILogcatUploader {
|
||||
override fun uploadCosFailed(data: CallbackData?) {
|
||||
if (data?.localPath == generatedZipPath) {
|
||||
Log.d(TAG, "---- uploadCosFailed ---: $data")
|
||||
trySend(UploadError(Reason(data.exception)))
|
||||
channel.trySend(UploadError(Reason(data.exception)))
|
||||
CosStatusCallbackManager.getInstance().unregister(this)
|
||||
}
|
||||
}
|
||||
@@ -58,8 +59,13 @@ internal class LogRecordUploader : ILogcatUploader {
|
||||
UploadManager.getInstance().uploadSingleFile(generatedZipPath)
|
||||
} catch (t: Throwable) {
|
||||
Log.d(TAG, "---- 上传失败 ---: ${t.message}")
|
||||
trySend(UploadError(Reason(t.message ?: "")))
|
||||
channel.send(UploadError(Reason(t.message ?: "")))
|
||||
}
|
||||
}.flowOn(ThreadUtils.getIoPool().asCoroutineDispatcher()).firstOrNull() ?: UploadError(Reason("UnKnown reason"))
|
||||
val iterator = channel.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
val next = iterator.next()
|
||||
emit(next)
|
||||
}
|
||||
}.flowOn(ThreadUtils.getIoPool().asCoroutineDispatcher()).filter { it is UploadError || it == UploadSuccess }.first()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user