Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Shamrock: ログスライス #78
Browse files Browse the repository at this point in the history
  • Loading branch information
whitechi73 committed Nov 25, 2023
1 parent 0de6f85 commit 5062ff7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions xposed/src/main/java/moe/fuqiuluo/shamrock/helper/LogCenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import moe.fuqiuluo.shamrock.utils.FileUtils
import moe.fuqiuluo.shamrock.xposed.actions.toast
import moe.fuqiuluo.shamrock.xposed.helper.internal.DataRequester
import mqq.app.MobileQQ
import java.io.File
import java.util.Date

internal enum class Level(
Expand All @@ -26,15 +27,28 @@ internal enum class Level(

@SuppressLint("SimpleDateFormat")
internal object LogCenter {
private val logFileBaseName = MobileQQ.getMobileQQ().qqProcessName.replace(":", ".") + "_${
// 格式化时间
SimpleDateFormat("yyyy-MM-dd").format(Date())
}_"
private val LogFile = MobileQQ.getContext().getExternalFilesDir(null)!!
.parentFile!!.resolve("Tencent/Shamrock/log").also {
if (it.exists()) it.delete()
it.mkdirs()
}.let {
var i = 1
lateinit var result: File
while (true) {
result = it.resolve("$logFileBaseName$i.log")
if (result.exists()) {
i++
} else {
break
}
}
return@let result
}
.resolve(MobileQQ.getMobileQQ().qqProcessName.replace(":", ".") + "_${
// 格式化时间
SimpleDateFormat("yyyy-MM-dd").format(Date())
}_" + ".log")

private val format = SimpleDateFormat("[HH:mm:ss] ")

fun log(string: String, level: Level = Level.INFO, toast: Boolean = false) =
Expand Down

0 comments on commit 5062ff7

Please sign in to comment.