Commit 5b638bfd by 严久程

声网日志

parent a97bba19
......@@ -29,10 +29,10 @@ class AudioLogUtils {
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeAgoraLog(content: String, fileName: String) {
fun writeAgoraLog(content: String, fileName: String, isAppend: Boolean = true) {
Observable.create<Any> {
try {
writeLog(content, fileName)
writeLog(content, fileName, isAppend)
if (BuildConfig.DEBUG) {
LogUtil.d("writeLog_complete")
}
......@@ -42,7 +42,7 @@ class AudioLogUtils {
.subscribe()
}
private fun writeLog(content: String, fileName: String) {
private fun writeLog(content: String, fileName: String, isAppend: Boolean) {
try {
val folder = getLogFolder()
val file = File(folder, fileName)
......@@ -51,19 +51,21 @@ class AudioLogUtils {
}
val fileWriter = FileWriter(file, true)
val writer = BufferedWriter(fileWriter)
writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine()
writer.write("UserUid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine()
writer.write("""DevicesInfo:${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()}""")
writer.newLine()
writer.write("""VersionInfo:${RxAppTool.getAppVersionName(BaseApp.getApp())}""")
writer.newLine()
writer.write("AgoraLog:$content")
writer.newLine()
writer.write("--------")
if (!isAppend) {
writer.write("----------------")
writer.newLine()
writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine()
writer.write("ExpertUid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine()
writer.write("""DevicesInfo:${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()}""")
writer.newLine()
writer.write("""VersionInfo:${RxAppTool.getAppVersionName(BaseApp.getApp())}""")
writer.newLine()
}
writer.write(content)
writer.newLine()
writer.flush()
writer.close()
......
......@@ -154,6 +154,8 @@ class LogHelper private constructor() {
val yunxinLog = getYunXinLog(BaseApp.getApp())
//声网日志
val agoraLog = getAgoraLog(BaseApp.getApp())
val agoraRtmLog = getAgoraRTMLog(BaseApp.getApp())
val agoraRtmBackLog = getAgoraRtmBackLog(BaseApp.getApp())
if (zipFile.exists()) zipFile.delete()
zipFile.createNewFile()
......@@ -167,6 +169,12 @@ class LogHelper private constructor() {
if (agoraLog.exists()) {
files.add(agoraLog)
}
if (agoraRtmLog.exists()) {
files.add(agoraRtmLog)
}
if (agoraRtmBackLog.exists()) {
files.add(agoraRtmBackLog)
}
// ZipUtils.toZip(getLogFolder().absolutePath, FileOutputStream(zipFile), true)
ZipUtils.toZip(files, FileOutputStream(zipFile))
......@@ -233,6 +241,20 @@ class LogHelper private constructor() {
return File(filePath)
}
//获取RTM日志
private fun getAgoraRTMLog(context: Context): File {
val agoraRTMLog = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorartm.log"
return File(agoraRTMLog)
}
//获取RTM备份日志
private fun getAgoraRtmBackLog(context: Context): File {
val agoraRTMLog = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorartm_1.log"
return File(agoraRTMLog)
}
private object Holder {
val INSTANCE = LogHelper()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment