From 31cf77e1c4b23fc3e2494daa6ae7174a6afe3462 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 6 Jun 2024 06:32:00 +0200 Subject: [PATCH] fix --- .../java/info/hannes/timber/DebugFormatTree.kt | 17 +++++++++++++++-- .../java/info/hannes/timber/FileLoggingTree.kt | 2 +- .../main/java/info/hannes/timber/CountlyTree.kt | 2 +- .../info/hannes/crashlytic/CrashlyticsTree.kt | 4 ++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt b/LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt index cb7afd8a..0468aca0 100644 --- a/LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt +++ b/LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt @@ -38,7 +38,7 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug } // if there is an JSON string, try to print out pretty - override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { var localMessage = message.trim() if (localMessage.startsWith("{") && localMessage.endsWith("}")) { try { @@ -47,6 +47,19 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug } catch (_: JSONException) { } } - super.logMessage(priority, tag, "$method: $localMessage", t, args) + super.log(priority, tag, "$method: $localMessage", t) } + + // if there is an JSON string, try to print out pretty +// override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { +// var localMessage = message.trim() +// if (localMessage.startsWith("{") && localMessage.endsWith("}")) { +// try { +// val json = JSONObject(message) +// localMessage = json.toString(3) +// } catch (_: JSONException) { +// } +// } +// super.logMessage(priority, tag, "$method: $localMessage", t, args) +// } } diff --git a/LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt b/LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt index 6e8c337e..f2085d76 100644 --- a/LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt +++ b/LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt @@ -45,7 +45,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil } @SuppressLint("LogNotTimber") - override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { try { val logTimeStamp = SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault()).format(Date()) diff --git a/LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt b/LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt index 7e946512..70180632 100644 --- a/LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt +++ b/LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt @@ -19,7 +19,7 @@ class CountlyTree(private val analytics: Analytics, private val serverIgnoreToke private val t = serverIgnoreToken private val regex: Regex = "$t.+?$t|$t[^$t]*$".toRegex() - override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { // we ignore INFO, DEBUG and VERBOSE if (priority <= Log.INFO) { return diff --git a/LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt b/LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt index ba761c19..88025365 100644 --- a/LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt +++ b/LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt @@ -8,12 +8,12 @@ import java.util.concurrent.atomic.AtomicBoolean @Suppress("unused") class CrashlyticsTree(private val identifier: String? = null) : Timber.Tree() { - override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { if (priority < Log.INFO) { return } - super.log(priority, tag, message, t, args) + super.log(priority, tag, message, t) FirebaseCrashlytics.getInstance().setCustomKey( "PRIORITY", when (priority) {