Skip to content

Commit 4743b8e

Browse files
committed
Use own timber
1 parent 4403a44 commit 4743b8e

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

LogcatCoreLib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
2727
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
2828
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
29-
api 'com.jakewharton.timber:timber:5.0.1'
29+
api 'com.github.hannesa2:timber:5.0.1.0'
3030
}
3131

3232
publishing {

LogcatCoreLib/src/main/java/info/hannes/timber/DebugFormatTree.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug
3434
}
3535

3636
// if there is an JSON string, try to print out pretty
37-
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
37+
override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
3838
var localMessage = message.trim()
3939
if (localMessage.startsWith("{") && localMessage.endsWith("}")) {
4040
try {
@@ -45,6 +45,6 @@ open class DebugFormatTree(private val newLogcat: Boolean = true) : Timber.Debug
4545
}
4646
if (newLogcat)
4747
localMessage = codeIdentifier + localMessage
48-
super.log(priority, tag, localMessage, t)
48+
super.logMessage(priority, tag, localMessage, t, args)
4949
}
5050
}

LogcatCoreLib/src/main/java/info/hannes/timber/FileLoggingTree.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
3333
init {
3434
externalCacheDir.let {
3535
if (!it.exists()) {
36-
if (!it.mkdirs())
37-
Log.e(LOG_TAG, "couldn't create ${it.absoluteFile}")
36+
if (!it.mkdirs()) Log.e(LOG_TAG, "couldn't create ${it.absoluteFile}")
3837
}
3938
val fileNameTimeStamp = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date())
4039
file = if (context != null) {
@@ -46,7 +45,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
4645
}
4746

4847
@SuppressLint("LogNotTimber")
49-
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
48+
override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
5049
try {
5150
val logTimeStamp = SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault()).format(Date())
5251

@@ -70,10 +69,8 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
7069
}
7170
}
7271

73-
if (Thread.currentThread().name == "main")
74-
_lastLogEntry.value = Event(textLine)
75-
else
76-
Handler(Looper.getMainLooper()).post { _lastLogEntry.value = Event(textLine) }
72+
if (Thread.currentThread().name == "main") _lastLogEntry.value = Event(textLine)
73+
else Handler(Looper.getMainLooper()).post { _lastLogEntry.value = Event(textLine) }
7774

7875
} catch (e: Exception) {
7976
// Log to prevent an endless loop

LogcatCountlyLib/src/main/java/info/hannes/timber/CountlyTree.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CountlyTree(private val analytics: Analytics, private val serverIgnoreToke
1919
private val t = serverIgnoreToken
2020
private val regex: Regex = "$t.+?$t|$t[^$t]*$".toRegex()
2121

22-
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
22+
override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
2323
// we ignore INFO, DEBUG and VERBOSE
2424
if (priority <= Log.INFO) {
2525
return

LogcatCrashlyticLib/src/main/java/info/hannes/crashlytic/CrashlyticsTree.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ import java.util.concurrent.atomic.AtomicBoolean
88
@Suppress("unused")
99
class CrashlyticsTree(private val identifier: String? = null) : Timber.Tree() {
1010

11-
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
11+
override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
1212
if (priority < Log.INFO) {
1313
return
1414
}
1515

16-
super.log(priority, tag, message, t)
16+
super.log(priority, tag, message, t, args)
1717

18-
FirebaseCrashlytics.getInstance().setCustomKey("PRIORITY", when (priority) {
19-
// 2 -> "Verbose"
20-
// 3 -> "Debug"
21-
4 -> "Info"
22-
5 -> "Warn"
23-
6 -> "Error"
24-
7 -> "Assert"
25-
else -> priority.toString()
26-
})
18+
FirebaseCrashlytics.getInstance().setCustomKey(
19+
"PRIORITY", when (priority) {
20+
// 2 -> "Verbose"
21+
// 3 -> "Debug"
22+
4 -> "Info"
23+
5 -> "Warn"
24+
6 -> "Error"
25+
7 -> "Assert"
26+
else -> priority.toString()
27+
}
28+
)
2729
tag?.let { FirebaseCrashlytics.getInstance().setCustomKey(KEY_TAG, it) }
2830
FirebaseCrashlytics.getInstance().setCustomKey(KEY_MESSAGE, message)
2931
FirebaseCrashlytics.getInstance().setCustomKey(KEY_UNIT_TEST, isRunningUnitTests.toString())

0 commit comments

Comments
 (0)