mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 08:39:37 +07:00

* Cleanup: platform specifics + UncivGame * Fix tests * Fix requests not clearing --------- Co-authored-by: vegeta1k95 <vfylfhby>
43 lines
1.2 KiB
Kotlin
43 lines
1.2 KiB
Kotlin
package com.unciv.app
|
|
|
|
import android.os.Build
|
|
import android.util.Log
|
|
import com.unciv.utils.LogBackend
|
|
import com.unciv.utils.Tag
|
|
|
|
private const val TAG_MAX_LENGTH = 23
|
|
|
|
class AndroidLogBackend : LogBackend {
|
|
|
|
override fun debug(tag: Tag, curThreadName: String, msg: String) {
|
|
Log.d(toAndroidTag(tag), "[$curThreadName] $msg")
|
|
}
|
|
|
|
override fun error(tag: Tag, curThreadName: String, msg: String) {
|
|
Log.e(toAndroidTag(tag), "[$curThreadName] $msg")
|
|
}
|
|
|
|
override fun isRelease(): Boolean {
|
|
return !BuildConfig.DEBUG
|
|
}
|
|
|
|
override fun getSystemInfo(): String {
|
|
return """
|
|
Device Model: ${Build.MODEL}
|
|
API Level: ${Build.VERSION.SDK_INT}
|
|
""".trimIndent()
|
|
}
|
|
}
|
|
|
|
private fun toAndroidTag(tag: Tag): String {
|
|
// This allows easy filtering of logcat by tag "Unciv"
|
|
val withUncivPrefix = if (tag.name.contains("unciv", true)) tag.name else "Unciv ${tag.name}"
|
|
|
|
// Limit was removed in Nougat
|
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N || tag.name.length <= TAG_MAX_LENGTH) {
|
|
withUncivPrefix
|
|
} else {
|
|
withUncivPrefix.substring(0, TAG_MAX_LENGTH)
|
|
}
|
|
}
|