Skip to content

Commit

Permalink
fix(logger): #305 missing no-op method parameters added (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
srtvprateek authored Mar 6, 2024
1 parent b8425e6 commit b84a1b0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any?>?) {}
fun event(tag: String, event: String, attributes: HashMap<String, Any?>? = null) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class PlutoTimberTree : Timber.Tree() {
}

@SuppressWarnings("UnusedPrivateMember", "EmptyFunctionBlock")
fun Timber.Tree.event(event: String, attr: HashMap<String, Any?>?) {}
fun Timber.Tree.event(event: String, attr: HashMap<String, Any?>? = null) {}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class PlutoTimberTree : Timber.Tree() {
}
}

fun Timber.Tree.event(event: String, attr: HashMap<String, Any?>?) {
fun Timber.Tree.event(event: String, attributes: HashMap<String, Any?>? = null) {
val moshi = Moshi.Builder().build()
val moshiAdapter: JsonAdapter<Map<String, Any?>?> = 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)}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class DemoLoggerFragment : Fragment(R.layout.fragment_demo_logger) {
"timestamp" to System.currentTimeMillis()
)
)
PlutoLog.event("demo", "event cta clicked without attrs")
}

/**
Expand All @@ -62,6 +63,7 @@ class DemoLoggerFragment : Fragment(R.layout.fragment_demo_logger) {
"timestamp" to System.currentTimeMillis()
)
)
Timber.tag("event").event("timber_event cta clicked")
}
}
}

0 comments on commit b84a1b0

Please sign in to comment.