diff --git a/core/src/main/java/tachiyomi/core/util/system/LogcatExtensions.kt b/core/src/main/java/tachiyomi/core/util/system/LogcatExtensions.kt index fb587b07d..b62e45139 100644 --- a/core/src/main/java/tachiyomi/core/util/system/LogcatExtensions.kt +++ b/core/src/main/java/tachiyomi/core/util/system/LogcatExtensions.kt @@ -7,12 +7,23 @@ import logcat.logcat inline fun Any.logcat( priority: LogPriority = LogPriority.DEBUG, throwable: Throwable? = null, + tag: String? = null, message: () -> String = { "" }, ) = logcat(priority = priority) { - var msg = message() - if (throwable != null) { - if (msg.isNotBlank()) msg += "\n" - msg += throwable.asLog() + val logMessage = StringBuilder() + + if (!tag.isNullOrEmpty()) { + logMessage.append("[$tag] ") } - msg + + val msg = message() + logMessage.append(msg) + + if (throwable != null) { + if (msg.isNotBlank()) logMessage.append("\n") + logMessage.append(throwable.asLog()) + } + + logMessage.toString() } +