[6.2.6][技术优化] 改成apm日志回捞
This commit is contained in:
@@ -10,6 +10,7 @@ import com.mogo.eagle.core.function.api.devatools.block.IMoGoBlockProvider;
|
||||
import com.mogo.eagle.core.function.api.devatools.perf.IMoGoCpuUsageProvider;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
import com.mogo.eagle.core.function.main.ARouterUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.VLogUtils;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -167,12 +168,7 @@ public class HookInvokerImpl implements IHookInvoker {
|
||||
}
|
||||
builder.setLength(builder.length() - 1);
|
||||
}
|
||||
|
||||
String s = builder.toString();
|
||||
|
||||
|
||||
//VLogUtils.w("HookHandler", "Junk Detected:" + builder, 4096);
|
||||
linkedLog(type, builder.toString());
|
||||
VLogUtils.w("HookHandler", builder.toString(), 4096);
|
||||
if (flag) {
|
||||
extra.setLength(0);
|
||||
}
|
||||
@@ -287,20 +283,4 @@ public class HookInvokerImpl implements IHookInvoker {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void linkedLog(Type type, String msg) {
|
||||
try {
|
||||
linkedLogInternal(type,msg);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_ANR_LEAK,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_HMI,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_MAIN_BLOCK,
|
||||
paramIndexes = { 0, 1 }
|
||||
)
|
||||
private void linkedLogInternal(Type type, String msg) {}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.mogo.eagle.core.block.runtime.report.*
|
||||
import com.mogo.eagle.core.function.api.devatools.block.*
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.VLogUtils
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
|
||||
internal class MoGoBlockProviderImpl: IMoGoBlockProvider, IBlockListener {
|
||||
@@ -20,8 +21,6 @@ internal class MoGoBlockProviderImpl: IMoGoBlockProvider, IBlockListener {
|
||||
@Volatile
|
||||
private var hasInit = false
|
||||
|
||||
private val linkedLog by lazy { MainBlockLinkedLog() }
|
||||
|
||||
override fun init(ctx: Context) {
|
||||
BlockDetector.init(BlockMetrics.Builder()
|
||||
.context(ctx)
|
||||
@@ -64,7 +63,11 @@ internal class MoGoBlockProviderImpl: IMoGoBlockProvider, IBlockListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
linkedLog.record(GsonUtils.toJson(map))
|
||||
try {
|
||||
VLogUtils.w("BLOCK", GsonUtils.toJson(map))
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.utilcode.util
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.util.Log
|
||||
import com.apm.insight.log.VLog
|
||||
|
||||
@@ -7,31 +9,58 @@ class VLogUtils {
|
||||
|
||||
companion object {
|
||||
|
||||
private val handler by lazy {
|
||||
HandlerThread("vlog_record").let {
|
||||
it.start()
|
||||
Handler(it.looper)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun d(tag: String, msg: String, max: Int = 4096) {
|
||||
handleMsg(msg, max).forEach {
|
||||
VLog.d(tag, it)
|
||||
val time = System.currentTimeMillis()
|
||||
handler.post {
|
||||
runCatching {
|
||||
handleMsg("time:$time, msg:$msg", max).forEach {
|
||||
VLog.d(tag, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun v(tag: String, msg: String, max: Int = 4096) {
|
||||
handleMsg(msg, max).forEach {
|
||||
VLog.v(tag, it)
|
||||
val time = System.currentTimeMillis()
|
||||
handler.post {
|
||||
runCatching {
|
||||
handleMsg("time:$time, msg:$msg", max).forEach {
|
||||
VLog.v(tag, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun w(tag: String, msg: String, max: Int = 4096) {
|
||||
handleMsg(msg, max).forEach {
|
||||
VLog.w(tag, it)
|
||||
val time = System.currentTimeMillis()
|
||||
handler.post {
|
||||
runCatching {
|
||||
handleMsg("time:$time, msg:$msg", max).forEach {
|
||||
VLog.w(tag, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun e(tag: String, msg: String, max: Int = 4096) {
|
||||
handleMsg(msg, max).forEach {
|
||||
VLog.e(tag, it)
|
||||
val time = System.currentTimeMillis()
|
||||
handler.post {
|
||||
runCatching {
|
||||
handleMsg("time:$time, msg:$msg", max).forEach {
|
||||
VLog.e(tag, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user