mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 13:29:17 +01:00
refactor: extend logcat to include tag.
This way can filter and tag the logs. Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
6e5d67b449
commit
e1eb2e3a86
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user