Skip to content

Commit

Permalink
[android] log
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Aug 15, 2024
1 parent f10c449 commit c62351a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
25 changes: 20 additions & 5 deletions GaiaXAndroidJS/src/main/kotlin/com/alibaba/gaiax/js/GXJSEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class GXJSEngine {
registerAssetsModules()
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.d("initModules() called with: e = $e")
}
}
}

Expand All @@ -97,15 +100,27 @@ class GXJSEngine {
allModules.putAll(bizModules)
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.d("registerAssetsModules() called with: e = $e")
}
}
}
}
allModules.forEach {
val clazz = Class.forName(it.value.toString())
if (clazz.superclass == GXJSBaseModule::class.java) {
registerModule(clazz as Class<out GXJSBaseModule>)
} else {
throw IllegalArgumentException("Register Module $clazz Illegal")
try {
Class.forName(it.value.toString())
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.d("registerAssetsModules() called with: e = $e")
}
null
}?.let { clazz ->
if (clazz.superclass == GXJSBaseModule::class.java) {
registerModule(clazz as Class<out GXJSBaseModule>)
} else {
throw IllegalArgumentException("Register Module $clazz Illegal")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ internal class QuickJSBridgeModule(private val hostContext: GXHostContext, priva
}
}
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.e("callSync() called with: e = $e")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ internal class GXModule(nativeModule: IGXModule) {
try {
return syncMethods[methodId]?.invoke(module, args)
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.d("invokeMethodSync() called with: exception message = ${e.message}")
}
e.printStackTrace()
}
return null
}
Expand All @@ -96,21 +96,21 @@ internal class GXModule(nativeModule: IGXModule) {
try {
asyncMethods[methodId]?.invoke(module, args)
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.d("invokeMethodAsync() called with: exception message = ${e.message}")
}
e.printStackTrace()
}
}

fun invokePromiseMethod(methodId: Long, args: JSONArray) {
try {
promiseMethods[methodId]?.invoke(module, args)
} catch (e: Exception) {
e.printStackTrace()
if (Log.isLog()) {
Log.d("invokePromiseMethod() called with: exception message = ${e.message}")
}
e.printStackTrace()
}
}

Expand Down

0 comments on commit c62351a

Please sign in to comment.