diff --git a/LogcatCoreLib/build.gradle b/LogcatCoreLib/build.gradle index 57d47286..614073ef 100644 --- a/LogcatCoreLib/build.gradle +++ b/LogcatCoreLib/build.gradle @@ -24,7 +24,7 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2" implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' - api 'com.jakewharton.timber:timber:5.0.1' + api 'com.github.hannesa2:timber:5.0.1.0' } publishing { diff --git a/LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt b/LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt index b8ca7311..767f300a 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 log(priority: Int, tag: String?, message: String, t: Throwable?) { + override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { var localMessage = message.trim() if (localMessage.startsWith("{") && localMessage.endsWith("}")) { try { @@ -47,6 +47,6 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug } catch (_: JSONException) { } } - super.log(priority, tag, "$method: $localMessage", t) + 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 03f5dbc3..6e8c337e 100644 --- a/LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt +++ b/LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt @@ -33,8 +33,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil init { externalCacheDir.let { if (!it.exists()) { - if (!it.mkdirs()) - Log.e(LOG_TAG, "couldn't create ${it.absoluteFile}") + if (!it.mkdirs()) Log.e(LOG_TAG, "couldn't create ${it.absoluteFile}") } val fileNameTimeStamp = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date()) file = if (context != null) { @@ -46,7 +45,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil } @SuppressLint("LogNotTimber") - override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { try { val logTimeStamp = SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault()).format(Date()) @@ -70,10 +69,8 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil } } - if (Thread.currentThread().name == "main") - _lastLogEntry.value = Event(textLine) - else - Handler(Looper.getMainLooper()).post { _lastLogEntry.value = Event(textLine) } + if (Thread.currentThread().name == "main") _lastLogEntry.value = Event(textLine) + else Handler(Looper.getMainLooper()).post { _lastLogEntry.value = Event(textLine) } } catch (e: Exception) { // Log to prevent an endless loop diff --git a/LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt b/LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt index 70180632..7e946512 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 log(priority: Int, tag: String?, message: String, t: Throwable?) { + override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { // 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 bc126dac..ba761c19 100644 --- a/LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt +++ b/LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt @@ -8,22 +8,24 @@ import java.util.concurrent.atomic.AtomicBoolean @Suppress("unused") class CrashlyticsTree(private val identifier: String? = null) : Timber.Tree() { - override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) { if (priority < Log.INFO) { return } - super.log(priority, tag, message, t) + super.log(priority, tag, message, t, args) - FirebaseCrashlytics.getInstance().setCustomKey("PRIORITY", when (priority) { - // 2 -> "Verbose" - // 3 -> "Debug" - 4 -> "Info" - 5 -> "Warn" - 6 -> "Error" - 7 -> "Assert" - else -> priority.toString() - }) + FirebaseCrashlytics.getInstance().setCustomKey( + "PRIORITY", when (priority) { + // 2 -> "Verbose" + // 3 -> "Debug" + 4 -> "Info" + 5 -> "Warn" + 6 -> "Error" + 7 -> "Assert" + else -> priority.toString() + } + ) tag?.let { FirebaseCrashlytics.getInstance().setCustomKey(KEY_TAG, it) } FirebaseCrashlytics.getInstance().setCustomKey(KEY_MESSAGE, message) FirebaseCrashlytics.getInstance().setCustomKey(KEY_UNIT_TEST, isRunningUnitTests.toString())