merge
This commit is contained in:
@@ -2,8 +2,8 @@ package com.mogo.eagle.core.function.call.devatools
|
||||
|
||||
import android.view.View
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult
|
||||
import com.mogo.eagle.core.data.chain.ChainLogParam
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainLogParam
|
||||
import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.mogo.eagle.core.function.call.devatools.scene
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneConstant.Companion.M_ADAS
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneConstant.Companion.M_DEVA
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneConstant.Companion.M_NETWORK
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneConstant.Companion.M_OTHER
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneConstant.Companion.M_ROUTE
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneLogCache
|
||||
import java.util.*
|
||||
|
||||
class Scene {
|
||||
|
||||
companion object {
|
||||
|
||||
private val sceneCache: MutableMap<String, SceneLogCache> =
|
||||
Collections.synchronizedMap(ArrayMap())
|
||||
|
||||
val scene: Scene by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
Scene()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
//初始化网络
|
||||
val networkMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_NETWORK] = networkMap
|
||||
|
||||
//初始化ADAS
|
||||
val adasMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_ADAS] = adasMap
|
||||
|
||||
//初始化deva
|
||||
val devaMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_DEVA] = devaMap
|
||||
|
||||
//初始化路径规划
|
||||
val routeMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_ROUTE] = routeMap
|
||||
|
||||
//初始化其他模块,方便定位索引
|
||||
val otherMap = SceneLogCache(mutableMapOf(), true)
|
||||
sceneCache[M_OTHER] = otherMap
|
||||
}
|
||||
|
||||
fun check(tag: String): Boolean {
|
||||
return if (canLog()) {
|
||||
classifyLog(tag)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
//前置收口
|
||||
private fun canLog(): Boolean {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* log分类,现阶段通过控制模块等级来限制,后续有需要再细分至模块对应类层级
|
||||
*/
|
||||
private fun classifyLog(tag: String): Boolean {
|
||||
var moduleName: String? = null
|
||||
var businessName: String? = null
|
||||
if (tag.contains("_")) {
|
||||
val tagSplit = tag.split("_")
|
||||
moduleName = tagSplit[0]
|
||||
if (tagSplit.size > 1) {
|
||||
businessName = tagSplit[1]
|
||||
}
|
||||
}
|
||||
|
||||
if (moduleName.isNullOrEmpty()) {
|
||||
val otherLogCache = sceneCache[M_OTHER]
|
||||
otherLogCache!!.tagMap!![tag] = true
|
||||
return otherLogCache.logger
|
||||
}
|
||||
|
||||
if (businessName.isNullOrEmpty()) {
|
||||
return false
|
||||
}
|
||||
|
||||
//此处存在用户自定义方式,可根据过滤找到对应不符合标准的模块
|
||||
var logCache = sceneCache[moduleName]
|
||||
if (logCache == null) {
|
||||
logCache = SceneLogCache(mutableMapOf(), true)
|
||||
logCache.tagMap!![businessName] = true
|
||||
}
|
||||
sceneCache[moduleName] = logCache
|
||||
return logCache.logger
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mogo.eagle.core.function.call.logger
|
||||
|
||||
import com.mogo.eagle.core.function.call.devatools.scene.Scene.Companion.scene
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
|
||||
object CallerLogger {
|
||||
|
||||
fun i(tag: String, message: String, any: Any) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.i(tag, message, any)
|
||||
}
|
||||
}
|
||||
|
||||
fun d(tag: String, message: String, any: Any) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.d(tag, message, any)
|
||||
}
|
||||
}
|
||||
|
||||
fun w(tag: String, message: String, any: Any) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.w(tag, message, any)
|
||||
}
|
||||
}
|
||||
|
||||
fun e(tag: String, message: String, any: Any) {
|
||||
if (scene.check(tag)) {
|
||||
Logger.e(tag, message, any)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user