Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-aman committed Sep 10, 2024
1 parent 4e08e30 commit f384d57
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class CustomerIOReactNativeLoggingEmitter(
}

fun sendEvent(params: WritableMap) {
println("I got control here")
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit(EVENT_NAME, params)
Expand All @@ -60,40 +59,33 @@ class CustomerIOReactNativeLoggingWrapper private constructor(
}

override fun debug(message: String) {
println("Hello, debug!")
emit(message, CioLogLevel.DEBUG)
}

override fun info(message: String) {
println("Hello, info!")
emit(message, CioLogLevel.INFO)
}

override fun error(message: String) {
println("Hello, error!")
emit(message, CioLogLevel.ERROR)
}

private fun emit(message: String, level: CioLogLevel) {
println("Hello, Emit!")
if (shouldEmit(level)) {

val data = buildMap {
put("logLevel", "info")
put("logLevel", level.name.lowercase())
put("message", message)
}
emitter?.sendEvent(Arguments.makeNativeMap(data))
}
}

private fun shouldEmit(level: CioLogLevel): Boolean {
println("Hello, shouldEmit!")
return when (logLevel) {
CioLogLevel.NONE -> false
CioLogLevel.ERROR -> level == CioLogLevel.ERROR
CioLogLevel.INFO -> level == CioLogLevel.ERROR || level == CioLogLevel.INFO
CioLogLevel.DEBUG -> true
}
}

}

0 comments on commit f384d57

Please sign in to comment.