Rename
This commit is contained in:
1 parent
b86d90021c
commit
6c0757c91b
972 files changed
+6885
-7321
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package io.legato.kazusa.constant
|
||||
|
||||
import android.util.Log
|
||||
import io.legato.kazusa.BuildConfig
|
||||
import io.legato.kazusa.help.config.AppConfig
|
||||
import io.legato.kazusa.utils.LogUtils
|
||||
import io.legato.kazusa.utils.toastOnUi
|
||||
import splitties.init.appCtx
|
||||
|
||||
object AppLog {
|
||||
|
||||
private val mLogs = arrayListOf<Triple<Long, String, Throwable?>>()
|
||||
|
||||
val logs get() = mLogs.toList()
|
||||
|
||||
@Synchronized
|
||||
fun put(message: String?, throwable: Throwable? = null, toast: Boolean = false) {
|
||||
message ?: return
|
||||
if (toast) {
|
||||
appCtx.toastOnUi(message)
|
||||
}
|
||||
if (mLogs.size > 100) {
|
||||
mLogs.removeLastOrNull()
|
||||
}
|
||||
if (throwable == null) {
|
||||
LogUtils.d("AppLog", message)
|
||||
} else {
|
||||
LogUtils.d("AppLog", "$message\n${throwable.stackTraceToString()}")
|
||||
}
|
||||
mLogs.add(0, Triple(System.currentTimeMillis(), message, throwable))
|
||||
if (BuildConfig.DEBUG) {
|
||||
val stackTrace = Thread.currentThread().stackTrace
|
||||
Log.e(stackTrace[3].className, message, throwable)
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun putNotSave(message: String?, throwable: Throwable? = null, toast: Boolean = false) {
|
||||
message ?: return
|
||||
if (toast) {
|
||||
appCtx.toastOnUi(message)
|
||||
}
|
||||
if (mLogs.size > 100) {
|
||||
mLogs.removeLastOrNull()
|
||||
}
|
||||
mLogs.add(0, Triple(System.currentTimeMillis(), message, throwable))
|
||||
if (BuildConfig.DEBUG) {
|
||||
val stackTrace = Thread.currentThread().stackTrace
|
||||
Log.e(stackTrace[3].className, message, throwable)
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun clear() {
|
||||
mLogs.clear()
|
||||
}
|
||||
|
||||
fun putDebug(message: String?, throwable: Throwable? = null) {
|
||||
if (AppConfig.recordLog) {
|
||||
put(message, throwable)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user