Add slf4j logging for kotlin jvm and android
This commit is contained in:
parent
f1c1524e61
commit
adb54e3b87
@ -1,6 +1,5 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
//apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
android {
|
||||
@ -24,15 +23,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
//task buildRust(type: Exec) {
|
||||
// workingDir '../'
|
||||
// commandLine './build.sh'
|
||||
//}
|
||||
|
||||
afterEvaluate {
|
||||
// android.libraryVariants.all { variant ->
|
||||
// variant.javaCompileProvider.get().dependsOn(buildRust)
|
||||
// }
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
@ -68,7 +59,9 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'androidx.core:core-ktx:1.5.0'
|
||||
|
||||
api "org.slf4j:slf4j-api:1.7.30"
|
||||
|
||||
androidTestImplementation 'com.github.tony19:logback-android:2.0.0'
|
||||
androidTestImplementation (project(':test-fixtures')) {
|
||||
exclude group: 'net.java.dev.jna', module: 'jna'
|
||||
}
|
||||
|
14
bdk-kotlin/android/src/androidTest/assets/logback.xml
Normal file
14
bdk-kotlin/android/src/androidTest/assets/logback.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<configuration>
|
||||
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
|
||||
<tagEncoder>
|
||||
<pattern>%logger{12}</pattern>
|
||||
</tagEncoder>
|
||||
<encoder>
|
||||
<pattern>[%-20thread] %msg</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="logcat" />
|
||||
</root>
|
||||
</configuration>
|
@ -20,6 +20,9 @@ dependencies {
|
||||
implementation platform('org.jetbrains.kotlin:kotlin-bom')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "net.java.dev.jna:jna:5.8.0"
|
||||
api "org.slf4j:slf4j-api:1.7.30"
|
||||
testImplementation "ch.qos.logback:logback-classic:1.2.3"
|
||||
testImplementation "ch.qos.logback:logback-core:1.2.3"
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
testImplementation (project(':test-fixtures'))
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ dependencies {
|
||||
implementation "net.java.dev.jna:jna:5.8.0"
|
||||
implementation (project(':jvm'))
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
api "org.slf4j:slf4j-api:1.7.30"
|
||||
}
|
||||
|
||||
java {
|
||||
|
@ -3,6 +3,8 @@ package org.bitcoindevkit.bdk
|
||||
import com.sun.jna.Native
|
||||
import org.junit.*
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@ -13,6 +15,8 @@ import kotlin.test.assertNull
|
||||
abstract class LibTest {
|
||||
|
||||
companion object {
|
||||
private val log: Logger = LoggerFactory.getLogger(LibTest::class.java)
|
||||
|
||||
private val bdkFfi: Lib = Native.load("bdk_ffi", Lib::class.java)
|
||||
private lateinit var wallet_result: Lib.WalletResult_t
|
||||
|
||||
@ -26,26 +30,26 @@ abstract class LibTest {
|
||||
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/1/*)"
|
||||
|
||||
wallet_result = bdkFfi.new_wallet_result(name, desc, change)
|
||||
//println("wallet created")
|
||||
log.debug("wallet created")
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@JvmStatic
|
||||
fun free_wallet() {
|
||||
bdkFfi.free_wallet_result(wallet_result)
|
||||
//println("wallet freed")
|
||||
log.debug("wallet freed")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wallet_sync_error() {
|
||||
val bad_wallet_result = bdkFfi.new_wallet_result("test", "bad", null)
|
||||
//println("wallet result created")
|
||||
log.debug("wallet result created")
|
||||
val sync_result = bdkFfi.sync_wallet(bad_wallet_result)
|
||||
val sync_err_pointer = bdkFfi.get_void_err(sync_result)
|
||||
assertNotNull(sync_err_pointer)
|
||||
val sync_err = sync_err_pointer!!.getString(0)
|
||||
//println("wallet sync error $sync_err")
|
||||
log.debug("wallet sync error $sync_err")
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -64,7 +68,7 @@ abstract class LibTest {
|
||||
|
||||
bdkFfi.free_string_result(address_result)
|
||||
bdkFfi.free_string(address_pointer)
|
||||
//println("address created from kotlin: $address")
|
||||
log.debug("address created from kotlin: $address")
|
||||
assertEquals(address, "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user