Skip to content

Commit 8be6eb2

Browse files
authored
Merge pull request #359 from AppDevNext/RevertDelegatorLogger
Revert delegator logger
2 parents 9959762 + 379aa5b commit 8be6eb2

9 files changed

Lines changed: 16 additions & 91 deletions

File tree

LogcatCoreLib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
2424
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.0"
2525
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.0'
26-
api 'com.github.hannesa2:timber:5.0.1.2'
26+
api 'com.jakewharton.timber:timber:5.0.1'
2727
}
2828

2929
project.afterEvaluate {

LogcatCoreLib/src/main/java/info/hannes/logcat/LoggingApplication.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.app.Application
44
import info.hannes.timber.DebugFormatTree
55
import timber.log.Timber
66

7-
open class LoggingApplication(private val delegator: Class<*>? = null) : Application() {
7+
open class LoggingApplication : Application() {
88

99
override fun onCreate() {
1010
super.onCreate()
@@ -14,6 +14,6 @@ open class LoggingApplication(private val delegator: Class<*>? = null) : Applica
1414
@Suppress("MemberVisibilityCanBePrivate")
1515
protected open fun setupLogging() {
1616
LoggingTools.globalErrorCatcher()
17-
Timber.plant(DebugFormatTree(delegator = delegator))
17+
Timber.plant(DebugFormatTree())
1818
}
1919
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.json.JSONException
44
import org.json.JSONObject
55
import timber.log.Timber
66

7-
open class DebugFormatTree(delegator: Class<*>? = null) : Timber.DebugTree(delegator = delegator) {
7+
open class DebugFormatTree : Timber.DebugTree() {
88

99
override fun createStackElementTag(element: StackTraceElement): String? {
1010
return String.format(
@@ -18,7 +18,7 @@ open class DebugFormatTree(delegator: Class<*>? = null) : Timber.DebugTree(deleg
1818
}
1919

2020
// if there is an JSON string, try to print out pretty
21-
override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
21+
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
2222
var localMessage = message.trim()
2323
if (localMessage.startsWith("{") && localMessage.endsWith("}")) {
2424
try {
@@ -27,6 +27,6 @@ open class DebugFormatTree(delegator: Class<*>? = null) : Timber.DebugTree(deleg
2727
} catch (e: JSONException) {
2828
}
2929
}
30-
super.logMessage(priority, tag, localMessage, t, *args)
30+
super.log(priority, tag, localMessage, t)
3131
}
3232
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
4141
}
4242

4343
@SuppressLint("LogNotTimber")
44-
override fun logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
44+
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
4545
try {
4646
val logTimeStamp = SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault()).format(Date())
4747

@@ -75,7 +75,7 @@ open class FileLoggingTree(externalCacheDir: File, context: Context? = null, fil
7575
}
7676
}
7777
// Don't call super, otherwise it logs twice
78-
//super.logMessage(priority, tag, message, t, args)
78+
//super.log(priority, tag, message, t)
7979
}
8080

8181
fun getFileName(): String = file.absolutePath

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 logMessage(priority: Int, tag: String?, message: String, t: Throwable?, vararg args: Any?) {
22+
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicBoolean
88
@Suppress("unused")
99
class CrashlyticsTree(private val identifier: String? = null) : Timber.Tree() {
1010

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

sample/src/main/java/info/hannes/logcat/CrashlyticApplication.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import info.hannes.timber.FileLoggingTree
1010
import timber.log.Timber
1111

1212

13-
class CrashlyticApplication : LoggingApplication(delegator = CustomLogger::class.java) {
14-
15-
private val logger = CustomLogger()
13+
class CrashlyticApplication : LoggingApplication() {
1614

1715
@SuppressLint("HardwareIds")
1816
override fun onCreate() {
@@ -25,15 +23,15 @@ class CrashlyticApplication : LoggingApplication(delegator = CustomLogger::class
2523
FirebaseCrashlytics.getInstance().setCustomKey("VERSION_NAME", BuildConfig.VERSIONNAME)
2624
Timber.plant(CrashlyticsTree(Settings.Secure.getString(applicationContext.contentResolver, Settings.Secure.ANDROID_ID)))
2725

28-
logger.d("Debug test")
29-
logger.i("Info test")
30-
logger.w("Warning test")
31-
logger.e("Error test")
26+
Timber.d("Debug test")
27+
Timber.i("Info test")
28+
Timber.w("Warning test")
29+
Timber.e("Error test")
3230

3331
var x = 0
3432
val runner: Runnable = object : Runnable {
3533
override fun run() {
36-
logger.d("live=$x")
34+
Timber.d("live=$x")
3735
x++
3836
Handler(Looper.getMainLooper()).postDelayed(this, 3000)
3937
}

sample/src/main/java/info/hannes/logcat/CustomLogger.kt

Lines changed: 0 additions & 51 deletions
This file was deleted.

sample/src/main/java/info/hannes/logcat/Logger.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)