From b84a1b02a3e926d22da245e190e40dc27ed07b3c Mon Sep 17 00:00:00 2001 From: Prateek Date: Wed, 6 Mar 2024 10:24:59 +0530 Subject: [PATCH] fix(logger): #305 missing no-op method parameters added (#306) --- .../src/main/java/com/pluto/plugins/logger/PlutoLog.kt | 2 +- .../src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt | 2 +- .../src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt | 4 ++-- .../java/com/sampleapp/functions/logger/DemoLoggerFragment.kt | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoLog.kt b/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoLog.kt index 8451c0e12..106999052 100644 --- a/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoLog.kt +++ b/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoLog.kt @@ -27,6 +27,6 @@ class PlutoLog private constructor() { fun wtf(tag: String, message: String, tr: Throwable? = null) {} @JvmStatic - fun event(tag: String, event: String, attributes: HashMap?) {} + fun event(tag: String, event: String, attributes: HashMap? = null) {} } } diff --git a/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt b/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt index b077a1f58..49957456b 100644 --- a/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt +++ b/pluto-plugins/plugins/logger/lib-no-op/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt @@ -8,4 +8,4 @@ class PlutoTimberTree : Timber.Tree() { } @SuppressWarnings("UnusedPrivateMember", "EmptyFunctionBlock") -fun Timber.Tree.event(event: String, attr: HashMap?) {} +fun Timber.Tree.event(event: String, attr: HashMap? = null) {} diff --git a/pluto-plugins/plugins/logger/lib/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt b/pluto-plugins/plugins/logger/lib/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt index e0fdb6d90..a15628eec 100644 --- a/pluto-plugins/plugins/logger/lib/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt +++ b/pluto-plugins/plugins/logger/lib/src/main/java/com/pluto/plugins/logger/PlutoTimberTree.kt @@ -70,8 +70,8 @@ class PlutoTimberTree : Timber.Tree() { } } -fun Timber.Tree.event(event: String, attr: HashMap?) { +fun Timber.Tree.event(event: String, attributes: HashMap? = null) { val moshi = Moshi.Builder().build() val moshiAdapter: JsonAdapter?> = moshi.adapter(Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java)) - log(LOG_EVENT_PRIORITY, "$event\t${moshiAdapter.toJson(attr)}") + log(LOG_EVENT_PRIORITY, "$event\t${moshiAdapter.toJson(attributes)}") } diff --git a/sample/src/main/java/com/sampleapp/functions/logger/DemoLoggerFragment.kt b/sample/src/main/java/com/sampleapp/functions/logger/DemoLoggerFragment.kt index 4b7861576..37d385bb6 100644 --- a/sample/src/main/java/com/sampleapp/functions/logger/DemoLoggerFragment.kt +++ b/sample/src/main/java/com/sampleapp/functions/logger/DemoLoggerFragment.kt @@ -45,6 +45,7 @@ class DemoLoggerFragment : Fragment(R.layout.fragment_demo_logger) { "timestamp" to System.currentTimeMillis() ) ) + PlutoLog.event("demo", "event cta clicked without attrs") } /** @@ -62,6 +63,7 @@ class DemoLoggerFragment : Fragment(R.layout.fragment_demo_logger) { "timestamp" to System.currentTimeMillis() ) ) + Timber.tag("event").event("timber_event cta clicked") } } }