[6.2.0][技术优化] 基于apm平台添加日志回捞能力

This commit is contained in:
renwj
2023-11-28 20:05:13 +08:00
parent 2f73803631
commit 7abb5d0de0
8 changed files with 30 additions and 9 deletions

View File

@@ -224,7 +224,7 @@ dependencies {
implementation rootProject.ext.dependencies.android_start_up
implementation rootProject.ext.dependencies.lancetx_runtime
if (!rootProject.isReleaseBuild()) {
if (!rootProject.isJunkDetectEnable()) {
implementation rootProject.ext.dependencies.lancetx_compiler_lib
implementation rootProject.ext.dependencies.handler_proxy_runtime
@@ -236,6 +236,8 @@ dependencies {
kapt rootProject.ext.dependencies.google_auto_service
compileOnly rootProject.ext.dependencies.google_auto_service
compileOnly rootProject.ext.dependencies.apm_insight
}
// implementation rootProject.ext.dependencies.mogocustommap

View File

@@ -2,7 +2,7 @@ package com.mogo.launcher.lancet.jank.spi;
import android.app.Activity;
import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import com.apm.insight.log.VLog;
import com.google.auto.service.AutoService;
import com.mogo.core.lancetx.compiler.lib.generator.Type;
import com.mogo.core.lancetx.compiler.lib.hook.IHookInvoker;
@@ -167,7 +167,7 @@ public class HookInvokerImpl implements IHookInvoker {
}
builder.setLength(builder.length() - 1);
}
Log.w("HookHandler", "Junk Detected:" + builder);
VLog.w("HookHandler", "Junk Detected:" + builder);
linkedLog(type, builder.toString());
if (flag) {
extra.setLength(0);

View File

@@ -171,3 +171,7 @@ boolean isReleaseBuild() {
}
return false
}
boolean isJunkDetectEnable() {
return isReleaseBuild()
}

View File

@@ -102,6 +102,10 @@ dependencies {
implementation project(':core:mogo-core-utils')
implementation project(':core:mogo-core-function-call')
implementation project(':core:mogo-core-res')
if (!rootProject.isJunkDetectEnable()) {
compileOnly rootProject.ext.dependencies.apm_insight
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -4,6 +4,7 @@ import android.content.*
import android.util.*
import android.view.*
import androidx.metrics.performance.*
import com.apm.insight.log.VLog
import com.mogo.eagle.core.block.runtime.*
import com.mogo.eagle.core.block.runtime.config.*
import com.mogo.eagle.core.block.runtime.config.recorder.*
@@ -17,6 +18,10 @@ import java.util.concurrent.TimeUnit.SECONDS
internal class MoGoBlockProviderImpl: IMoGoBlockProvider, IBlockListener {
companion object {
private const val TAG = "BLOCK_REPORT"
}
@Volatile
private var hasInit = false
@@ -64,7 +69,13 @@ internal class MoGoBlockProviderImpl: IMoGoBlockProvider, IBlockListener {
}
}
}
linkedLog.record(GsonUtils.toJson(map))
val msg = GsonUtils.toJson(map)
try {
VLog.w(TAG, msg)
} catch (t: Throwable) {
Log.e(TAG, "onDumped error", t)
}
linkedLog.record(msg)
}
})
}

View File

@@ -1,6 +1,6 @@
apply plugin: 'bytex.handler_proxy'
handler_proxy {
enable !rootProject.isReleaseBuild()
enableInDebug !rootProject.isReleaseBuild()
enable !rootProject.isJunkDetectEnable()
enableInDebug !rootProject.isJunkDetectEnable()
}

View File

@@ -8,7 +8,7 @@ LancetX {
"com.zhjt.mogo_core_function_devatools.perf"
]
synchronizedLock {
enabled !rootProject.isReleaseBuild()
enabled !rootProject.isJunkDetectEnable()
blackList = [
"okio.AsyncTimeout\$Watchdog"
]
@@ -28,7 +28,7 @@ LancetX {
enable true
}
main_block_check {
enable !rootProject.isReleaseBuild()
enable !rootProject.isJunkDetectEnable()
}
}
}

View File

@@ -288,7 +288,7 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider {
ApmInsight.getInstance().init(context, builder.build());
//初始化自定日志配置自定义日志最大占用磁盘内部一般配置20,代表最大20M磁盘占用。1.4.1版本开始存在这个api
VLog.init(context, 20);
VLog.init(context, 50);
}
}