Commit 670dc5ae authored by Ricki Hirner's avatar Ricki Hirner 🐑

Abbreviate too long log messages to reduce OOM errors

parent 7d6a052e
......@@ -8,18 +8,21 @@
package at.bitfire.davdroid.log
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.exception.ExceptionUtils
import org.apache.commons.lang3.time.DateFormatUtils
import java.util.logging.Formatter
import java.util.logging.LogRecord
class PlainTextFormatter private constructor(
val logcat: Boolean
private val logcat: Boolean
): Formatter() {
companion object {
@JvmField val LOGCAT = PlainTextFormatter(true)
@JvmField val DEFAULT = PlainTextFormatter(false)
override fun format(r: LogRecord): String {
......@@ -33,7 +36,7 @@ class PlainTextFormatter private constructor(
if (className != r.loggerName)
builder.append("[").append(className).append("] ")
builder.append(StringUtils.abbreviate(r.message, MAX_MESSAGE_LENGTH))
r.thrown?.let {
builder .append("\nEXCEPTION ")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment