mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: ログスライス #78
This commit is contained in:
parent
0de6f851a6
commit
5062ff7c3a
@ -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(
|
||||
@ -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) =
|
||||
|
Loading…
x
Reference in New Issue
Block a user