change some logger logic

This commit is contained in:
zhongchao
2022-03-15 10:50:57 +08:00
parent 6102e55ed3
commit 336b752a54
4 changed files with 23 additions and 17 deletions

View File

@@ -105,7 +105,7 @@ class CronTaskManager(private var context: Context?) {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
cameraList = it
CallerLogger.d("$M_MONITOR$TAG", "requestDeviceList返回结果为$it")
// CallerLogger.d("$M_MONITOR$TAG", "requestDeviceList返回结果为$it")
}, {
it.printStackTrace()
CallerLogger.e(
@@ -138,7 +138,7 @@ class CronTaskManager(private var context: Context?) {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
carCameraList = it
CallerLogger.d("$M_MONITOR$TAG", "requestCarCameraList返回结果为$it")
// CallerLogger.d("$M_MONITOR$TAG", "requestCarCameraList返回结果为$it")
}, {
CallerLogger.e(
"$M_MONITOR$TAG",

View File

@@ -4,27 +4,27 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.Scene.Companion.scene
object CallerLogger {
fun i(tag: String, message: String) {
fun i(tag: String, message: Any? = null) {
if (scene.check(tag)) {
Logger.i(tag, message, null)
Logger.i(tag, message.toString(), null)
}
}
fun d(tag: String, message: String) {
fun d(tag: String, message: Any? = null) {
if (scene.check(tag)) {
Logger.d(tag, message, null)
Logger.d(tag, message.toString(), null)
}
}
fun w(tag: String, message: String) {
fun w(tag: String, message: Any? = null) {
if (scene.check(tag)) {
Logger.w(tag, message, null)
Logger.w(tag, message.toString(), null)
}
}
fun e(tag: String, message: String) {
fun e(tag: String, message: Any? = null) {
if (scene.check(tag)) {
Logger.e(tag, message, null)
Logger.e(tag, message.toString(), null)
}
}

View File

@@ -8,6 +8,9 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OLD_ROUTE
import java.util.*
/**
* 场景日志,提供场景过滤服务
*/
class Scene {
companion object {
@@ -40,11 +43,16 @@ class Scene {
//初始化其他模块,方便定位索引
val otherMap = SceneLogCache(mutableMapOf(), true)
sceneCache[M_OTHER] = otherMap
//todo 1. SceneLogCache增加模块名称提供场景需要
//todo 2. 对特定场景提供数据, 网约车,调度...
}
fun check(tag: String): Boolean {
return if (canLog()) {
classifyLog(tag)
// classifyLog(tag)
true
} else {
false
}
@@ -76,15 +84,13 @@ class Scene {
return otherLogCache.logger
}
if (businessName.isNullOrEmpty()) {
return false
}
//此处存在用户自定义方式,可根据过滤找到对应不符合标准的模块
var logCache = sceneCache[moduleName]
if (logCache == null) {
logCache = SceneLogCache(mutableMapOf(), true)
logCache.tagMap!![businessName] = true
businessName?.let {
logCache.tagMap!![it] = true
}
}
sceneCache[moduleName] = logCache
return logCache.logger

View File

@@ -25,6 +25,6 @@ class SceneConstant {
//旧module
const val M_OLD_ROUTE = "OLD-ROUTE-SERVICE_"
const val M_OLD_OTHER = "OLD-OTHER-SERVICE_"
const val M_OTHER = "ALL-MODULES_"
const val M_OTHER = "ALL_OLD-MODULES_"
}
}