[sonar] trace log

This commit is contained in:
zhongchao
2023-10-30 14:25:02 +08:00
parent 5b910c2082
commit 1436ddc053
24 changed files with 88 additions and 70 deletions

View File

@@ -173,7 +173,7 @@ class DevaToolsProvider : IDevaToolsProvider {
if (plugin is TracePlugin) {
if (tag == SharePluginInfo.TAG_PLUGIN_EVIL_METHOD) {
isEvil = true
printEvilMsg(issue.toString())
printEvilMsg(mapOf("evilMethod" to issue.toString()))
}
}
}
@@ -216,7 +216,7 @@ class DevaToolsProvider : IDevaToolsProvider {
nodeAliasCode = ChainConstant.CHAIN_CODE_RECORD_ANR,
paramIndexes = [0]
)
private fun printEvilMsg(evilMethod: String) {
private fun printEvilMsg(evilMethod: Map<String,String>) {
w("TraceCanary", evilMethod)
}

View File

@@ -6,7 +6,7 @@ import android.widget.Toast
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_INIT_ENV_RESTART
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_SOURCE_INIT
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_INIT_STATUS
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_STATUS
import com.mogo.eagle.core.function.api.devatools.apm.*
import com.mogo.eagle.core.utilcode.util.*
import com.zhjt.mogo_core_function_devatools.apm.config.*
@@ -84,7 +84,7 @@ class ApmEnvProviderImpl: IApmEnvProvider, CoroutineScope {
val appRelaunched = ApmEnvConfig.isAppRelaunched()
if ((!isEnvValid || (buildTypeChanged || netTypeChanged || dockerVersionChanged)) && !appRelaunched) {
ApmEnvConfig.setAppRelaunched(true)
restartApp("buildType:$buildType,netType:$netType,dockerVersion:$dockerVersion")
restartApp(mapOf<String,Any>("buildType" to buildType, "netType" to netType,"dockerVersion" to dockerVersion))
return@launch
}
if (isFirstDockerVersionSet) {
@@ -110,12 +110,12 @@ class ApmEnvProviderImpl: IApmEnvProvider, CoroutineScope {
}
@ChainLog(
linkChainLog = CHAIN_TYPE_INIT_STATUS,
linkChainLog = CHAIN_TYPE_STATUS,
linkCode = CHAIN_SOURCE_INIT,
nodeAliasCode = CHAIN_CODE_INIT_ENV_RESTART,
paramIndexes = [0]
)
private fun restartApp(envStr:String) {
private fun restartApp(envStr:Map<String,Any>) {
launch(Dispatchers.Main) {
Toast.makeText(Utils.getApp(), "发现系统环境不一致,正在重启...", Toast.LENGTH_SHORT).show()
delay(50)

View File

@@ -8,6 +8,7 @@ import com.mogo.eagle.core.data.deva.bindingcar.BindingCarInfo
import com.mogo.eagle.core.data.deva.bindingcar.BindingCarRequest
import com.mogo.eagle.core.data.deva.bindingcar.ModifyBindingcarInfo
import com.mogo.eagle.core.data.config.HdMapBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBindingCarDialog
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showModifyBindingCarDialog
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
@@ -20,6 +21,7 @@ import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.zhjt.mogo_core_function_devatools.R
import com.zhjt.service.chain.ChainLog
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
@@ -65,6 +67,7 @@ class BindingCarNetWorkManager private constructor() {
MediaType.get("application/json;charset=UTF-8"),
GsonUtil.jsonFromObject(request)
)
bindLog(mapOf("bingReq" to request))
mBindingCarApiService.getBindingCarInfo(requestBody)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@@ -72,7 +75,7 @@ class BindingCarNetWorkManager private constructor() {
override fun onSubscribe(d: Disposable) {}
override fun onNext(info: BindingCarInfo) {
if (info != null && info.getData() != null) {
d(SceneConstant.M_DEVA + TAG, "getBindingCarInfo data =" + info.getData().toString() + "---getDefaultId() : ${getDefaultId()}")
bindLog(mapOf("bindResult" to true,"carType" to getDefaultId(),"msg" to info))
SharedPrefsMgr.getInstance(context).putString(
SharedPrefsConstants.CAR_INFO,
GsonUtils.toJson(info.getData())
@@ -91,6 +94,7 @@ class BindingCarNetWorkManager private constructor() {
override fun onError(e: Throwable) {
SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.CAR_INFO, "")
bindLog(mapOf("bindResult" to false,"msg" to e.toString()))
e(SceneConstant.M_DEVA + TAG, "getBindingCarInfo onError e = " + e.toString() + "---e.getMessage = " + e.message + "---getDefaultId() : ${getDefaultId()}")
}
@@ -115,6 +119,7 @@ class BindingCarNetWorkManager private constructor() {
widevineIDWithMd5,
screenType
)
bindLog(mapOf("bindingReq" to request))
val requestBody = RequestBody.create(
MediaType.get("application/json;charset=UTF-8"),
GsonUtil.jsonFromObject(request)
@@ -127,13 +132,13 @@ class BindingCarNetWorkManager private constructor() {
override fun onNext(info: ModifyBindingcarInfo) {
if (info != null) {
callBack.invoke(info)
d(SceneConstant.M_DEVA + TAG, "modifyBindingCar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString())
bindLog(mapOf("bindingStatus" to true,"bindMsg" to info))
updateCarVrIconRes(info.data.brandId)
}
}
override fun onError(e: Throwable) {
e(SceneConstant.M_DEVA + TAG, "modifyBindingCar onError e = " + e.toString() + "---e.getMessage = " + e.message)
bindLog(mapOf("bindingStatus" to false,"bindMsg" to e.toString()))
}
override fun onComplete() {}
@@ -177,6 +182,16 @@ class BindingCarNetWorkManager private constructor() {
}
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_INIT,
nodeAliasCode = ChainConstant.CHAIN_CODE_BINDING_CAR,
paramIndexes = [0]
)
private fun bindLog(msg:Map<String,Any>){
d(SceneConstant.M_DEVA + TAG, "bindLog : $msg")
}
private fun getDefaultId(): String {
return when (HdMapBuildConfig.currentCarVrIconRes) {
R.raw.chuzuche -> "1"

View File

@@ -14,7 +14,7 @@ internal class MainBlockLinkedLog {
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_HMI,
linkChainLog = ChainConstant.CHAIN_TYPE_ANR_LEAK,
linkCode = ChainConstant.CHAIN_SOURCE_HMI,
nodeAliasCode = ChainConstant.CHAIN_CODE_MAIN_BLOCK,
paramIndexes = [0]

View File

@@ -6,7 +6,7 @@ import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_FUNC_CONFIG_CHANGED
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_SOURCE_CLOUD
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_INIT_STATUS
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_STATUS
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsFuncConfigListenerManager
@@ -71,7 +71,7 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig>, IMoGoAutopilotCarCo
}
@ChainLog(
linkChainLog = CHAIN_TYPE_INIT_STATUS,
linkChainLog = CHAIN_TYPE_STATUS,
linkCode = CHAIN_SOURCE_CLOUD,
nodeAliasCode = CHAIN_CODE_FUNC_CONFIG_CHANGED,
paramIndexes = [0]

View File

@@ -14,7 +14,7 @@ internal class MoFangLinkedLog {
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_HMI,
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_HMI,
nodeAliasCode = ChainConstant.CHAIN_CODE_MO_FANG_CONNECT,
paramIndexes = [0]

View File

@@ -51,7 +51,7 @@ object SyncConfig {
}
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_INIT_STATUS,
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_INIT,
nodeAliasCode = ChainConstant.CHAIN_CODE_APP_INFO_CONFIG_UPDATE,
paramIndexes = [0]

View File

@@ -3,7 +3,6 @@ package com.zhjt.mogo_core_function_devatools.trace
import android.content.Context
import android.os.Handler
import android.os.Looper
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.deva.chain.ChainLogParam
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
@@ -58,7 +57,7 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
CallerAutopilotCarConfigListenerManager.addListener(TAG, this)
// Trace过程中进行日志抓取对日志进行配置
fwBuildMap[ChainConstant.CHAIN_TYPE_INIT_STATUS] =
fwBuildMap[ChainConstant.CHAIN_TYPE_STATUS] =
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_INIT)
fwBuildMap[ChainConstant.CHAIN_TYPE_GNSS] =
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_GNSS)
@@ -72,8 +71,6 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
FwBuild(false, 30, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_VEHICLE)
fwBuildMap[ChainConstant.CHAIN_TYPE_SOCKET_TRAFFIC_LIGHT] =
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_ADAS_TRAFFIC_LIGHT)
fwBuildMap[ChainConstant.CHAIN_TYPE_HMI] =
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_HMI_ACTIONS)
fwBuildMap[ChainConstant.CHAIN_TYPE_ANR_LEAK] =
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_RECORD_ANR)
fwBuildMap[ChainConstant.CHAIN_TYPE_V2X] =
@@ -86,7 +83,7 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_OCH)
traceInfoCache[ChainConstant.CHAIN_TYPE_INIT_STATUS] =
traceInfoCache[ChainConstant.CHAIN_TYPE_STATUS] =
ChainLogParam(true, "INIT状态")
traceInfoCache[ChainConstant.CHAIN_TYPE_GNSS] =
ChainLogParam(true, "ADAS自车定位")
@@ -100,8 +97,6 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
ChainLogParam(false, "ADAS车辆底盘数据")
traceInfoCache[ChainConstant.CHAIN_TYPE_SOCKET_TRAFFIC_LIGHT] =
ChainLogParam(true, "红绿灯Union数据")
traceInfoCache[ChainConstant.CHAIN_TYPE_HMI] =
ChainLogParam(true, "人机交互行为")
traceInfoCache[ChainConstant.CHAIN_TYPE_ANR_LEAK] =
ChainLogParam(true, "ANR Record")
traceInfoCache[ChainConstant.CHAIN_TYPE_V2X] =
@@ -156,7 +151,7 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
fun refreshTraceInfo(map: HashMap<Int, ChainLogParam>) {
map.forEach { (type, param) ->
if (type != ChainConstant.CHAIN_TYPE_INIT_STATUS) {
if (type != ChainConstant.CHAIN_TYPE_STATUS) {
val fwBuild = this.fwBuildMap[type]
fwBuild?.let {
CallerLogger.d("$M_DEVA$TAG", "param : ${param.des} , record : ${param.record}")

View File

@@ -301,7 +301,7 @@ class MoGoUpgradeProviderImpl: IMoGoUpgradeProvider {
@ChainLog(
linkChainLog = ChainConstant.CHAIN_TYPE_INIT_STATUS,
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
linkCode = ChainConstant.CHAIN_SOURCE_CLOUD,
nodeAliasCode = ChainConstant.CHAIN_CODE_UPGRADE_APP,
paramIndexes = [0]