Remove obsolete log tag length check
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package gq.kirmanak.mealient.logging
|
package gq.kirmanak.mealient.logging
|
||||||
|
|
||||||
import android.os.Build
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@@ -15,15 +14,8 @@ class LogcatAppender @Inject constructor() : Appender {
|
|||||||
override fun isLoggable(logLevel: LogLevel, tag: String): Boolean = isLoggable
|
override fun isLoggable(logLevel: LogLevel, tag: String): Boolean = isLoggable
|
||||||
|
|
||||||
override fun log(logLevel: LogLevel, tag: String, message: String) {
|
override fun log(logLevel: LogLevel, tag: String, message: String) {
|
||||||
// Tag length limit was removed in API 26.
|
|
||||||
val logTag = if (tag.length <= MAX_TAG_LENGTH || Build.VERSION.SDK_INT >= 26) {
|
|
||||||
tag
|
|
||||||
} else {
|
|
||||||
tag.substring(0, MAX_TAG_LENGTH)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.length < MAX_LOG_LENGTH) {
|
if (message.length < MAX_LOG_LENGTH) {
|
||||||
Log.println(logLevel.priority, logTag, message)
|
Log.println(logLevel.priority, tag, message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +28,7 @@ class LogcatAppender @Inject constructor() : Appender {
|
|||||||
do {
|
do {
|
||||||
val end = newline.coerceAtMost(i + MAX_LOG_LENGTH)
|
val end = newline.coerceAtMost(i + MAX_LOG_LENGTH)
|
||||||
val part = message.substring(i, end)
|
val part = message.substring(i, end)
|
||||||
Log.println(logLevel.priority, logTag, part)
|
Log.println(logLevel.priority, tag, part)
|
||||||
i = end
|
i = end
|
||||||
} while (i < newline)
|
} while (i < newline)
|
||||||
i++
|
i++
|
||||||
@@ -45,7 +37,6 @@ class LogcatAppender @Inject constructor() : Appender {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val MAX_LOG_LENGTH = 4000
|
private const val MAX_LOG_LENGTH = 4000
|
||||||
private const val MAX_TAG_LENGTH = 23
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user