Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package at.bitfire.davdroid.log

import com.google.common.base.Ascii
import java.io.PrintWriter
import java.io.StringWriter
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -42,6 +43,11 @@ class PlainTextFormatter(
lineSeparator = System.lineSeparator()
)

/**
* Maximum length of a log line (estimate).
*/
const val MAX_LENGTH = 10000

fun shortClassName(className: String) = className
.replace(Regex("^at\\.bitfire\\.(dav|cert4an|dav4an|ical4an|vcard4an)droid\\."), ".")
.replace(Regex("\\$.*$"), "")
Expand Down Expand Up @@ -72,7 +78,7 @@ class PlainTextFormatter(
}
}

builder.append(r.message)
builder.append(truncate(r.message))

if (withException && r.thrown != null) {
val indentedStackTrace = stackTrace(r.thrown)
Expand All @@ -83,7 +89,7 @@ class PlainTextFormatter(

r.parameters?.let {
for ((idx, param) in it.withIndex())
builder.append("\n\tPARAMETER #").append(idx).append(" = ").append(param)
builder.append("\n\tPARAMETER #").append(idx).append(" = ").append(truncate(param.toString()))
}

if (lineSeparator != null)
Expand All @@ -92,4 +98,7 @@ class PlainTextFormatter(
return builder.toString()
}

private fun truncate(s: String) =
Ascii.truncate(s, MAX_LENGTH, "[…]")

}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ androidx-work = "2.9.1"
bitfire-cert4android = "f1cc9b9ca3"
bitfire-dav4jvm = "fbd95a5f5a"
bitfire-ical4android = "b75f33972a"
bitfire-vcard4android = "505848a85a"
bitfire-vcard4android = "5439c1f63c"
compose-accompanist = "0.36.0"
compose-bom = "2024.09.03"
dnsjava = "3.6.0"
Expand Down
Loading