新增日志
This commit is contained in:
parent
7847159a61
commit
468f1255e4
|
|
@ -0,0 +1,159 @@
|
|||
package com.gamedog.statisticreporter
|
||||
|
||||
import android.util.Log
|
||||
import com.remax.bill.BuildConfig
|
||||
|
||||
/**
|
||||
* 广告日志工具类
|
||||
* 提供统一的日志输出控制和管理
|
||||
*/
|
||||
object StatisticLogger {
|
||||
private const val TAG = "StatisticModule"
|
||||
|
||||
/**
|
||||
* 日志开关,默认为true
|
||||
*/
|
||||
private var isLogEnabled = BuildConfig.DEBUG
|
||||
|
||||
/**
|
||||
* 设置日志开关
|
||||
* @param enabled 是否启用日志
|
||||
*/
|
||||
fun setLogEnabled(enabled: Boolean) {
|
||||
isLogEnabled = enabled
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志开关状态
|
||||
* @return 是否启用日志
|
||||
*/
|
||||
fun isLogEnabled(): Boolean = isLogEnabled
|
||||
|
||||
/**
|
||||
* Debug日志
|
||||
* @param message 日志消息
|
||||
*/
|
||||
fun d(message: String) {
|
||||
if (isLogEnabled) {
|
||||
Log.d(TAG, message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug日志(带参数)
|
||||
* @param message 日志消息模板
|
||||
* @param args 参数列表
|
||||
*/
|
||||
fun d(message: String, vararg args: Any?) {
|
||||
if (isLogEnabled) {
|
||||
Log.d(TAG, message.format(*args))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning日志
|
||||
* @param message 日志消息
|
||||
*/
|
||||
fun w(message: String) {
|
||||
if (isLogEnabled) {
|
||||
Log.w(TAG, message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning日志(带参数)
|
||||
* @param message 日志消息模板
|
||||
* @param args 参数列表
|
||||
*/
|
||||
fun w(message: String, vararg args: Any?) {
|
||||
if (isLogEnabled) {
|
||||
Log.w(TAG, message.format(*args))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error日志
|
||||
* @param message 日志消息
|
||||
*/
|
||||
fun e(message: String) {
|
||||
if (isLogEnabled) {
|
||||
Log.e(TAG, message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error日志(带异常)
|
||||
* @param message 日志消息
|
||||
* @param throwable 异常对象
|
||||
*/
|
||||
fun e(message: String, throwable: Throwable?) {
|
||||
if (isLogEnabled) {
|
||||
Log.e(TAG, message, throwable)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error日志(带参数)
|
||||
* @param message 日志消息模板
|
||||
* @param args 参数列表
|
||||
*/
|
||||
fun e(message: String, vararg args: Any?) {
|
||||
if (isLogEnabled) {
|
||||
Log.e(TAG, message.format(*args))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error日志(带参数和异常)
|
||||
* @param message 日志消息模板
|
||||
* @param throwable 异常对象
|
||||
* @param args 参数列表
|
||||
*/
|
||||
fun e(message: String, throwable: Throwable?, vararg args: Any?) {
|
||||
if (isLogEnabled) {
|
||||
Log.e(TAG, message.format(*args), throwable)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Info日志
|
||||
* @param message 日志消息
|
||||
*/
|
||||
fun i(message: String) {
|
||||
if (isLogEnabled) {
|
||||
Log.i(TAG, message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Info日志(带参数)
|
||||
* @param message 日志消息模板
|
||||
* @param args 参数列表
|
||||
*/
|
||||
fun i(message: String, vararg args: Any?) {
|
||||
if (isLogEnabled) {
|
||||
Log.i(TAG, message.format(*args))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verbose日志
|
||||
* @param message 日志消息
|
||||
*/
|
||||
fun v(message: String) {
|
||||
if (isLogEnabled) {
|
||||
Log.v(TAG, message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verbose日志(带参数)
|
||||
* @param message 日志消息模板
|
||||
* @param args 参数列表
|
||||
*/
|
||||
fun v(message: String, vararg args: Any?) {
|
||||
if (isLogEnabled) {
|
||||
Log.v(TAG, message.format(*args))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.gamedog.statisticreporter.firbase.FireBaseManager
|
|||
import com.gamedog.statisticreporter.shushu.ShushuManager
|
||||
import com.remax.base.report.DataReportManager
|
||||
import com.remax.base.report.DataReporter
|
||||
import com.remax.bill.BuildConfig
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
|
@ -58,6 +59,10 @@ object StatisticUtil {
|
|||
mBgScope.launch {
|
||||
FireBaseManager.instance().reportEvent(eventKey, eventData)
|
||||
ShushuManager.instance().reportEvent(eventKey, eventData)
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
StatisticLogger.d("Events reported to shushu&Firebase: type=$eventKey")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,18 @@
|
|||
package com.gamedog.statisticreporter.shushu
|
||||
|
||||
import android.os.Bundle
|
||||
import cn.thinkingdata.analytics.BuildConfig
|
||||
|
||||
import cn.thinkingdata.analytics.TDAnalytics
|
||||
import cn.thinkingdata.analytics.TDAnalytics.TDAutoTrackEventType
|
||||
import cn.thinkingdata.analytics.TDAnalyticsAPI
|
||||
import cn.thinkingdata.analytics.TDConfig
|
||||
import cn.thinkingdata.analytics.ThinkingAnalyticsSDK
|
||||
import com.ama.core.architecture.BaseApp
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
|
||||
|
||||
|
||||
class ShushuManager private constructor() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue