Add API response logging

This commit is contained in:
Erik C. Thauvin 2025-03-26 23:32:56 -07:00
parent 75ccf1a0ed
commit eed8277ed6
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 16 additions and 1 deletions

View file

@ -52,7 +52,7 @@ class CryptoPrices : AbstractModule() {
/**
* Returns the cryptocurrency market price from
* [Coinbase](https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-spot-price).
* [Coinbase](https://docs.cdp.coinbase.com/coinbase-app/docs/api-prices#get-spot-price).
*/
override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) {
if (CURRENCIES.isEmpty()) {

View file

@ -39,6 +39,9 @@ import net.thauvin.erik.crypto.CryptoPrice
import net.thauvin.erik.mobibot.modules.CryptoPrices.Companion.currentPrice
import net.thauvin.erik.mobibot.modules.CryptoPrices.Companion.getCurrencyName
import net.thauvin.erik.mobibot.modules.CryptoPrices.Companion.loadCurrencies
import org.junit.jupiter.api.BeforeAll
import java.util.logging.ConsoleHandler
import java.util.logging.Level
import kotlin.test.Test
class CryptoPricesTest {
@ -69,4 +72,16 @@ class CryptoPricesTest {
assertThat(getCurrencyName("USD"), "USD").isEqualTo("United States Dollar")
assertThat(getCurrencyName("EUR"), "EUR").isEqualTo("Euro")
}
companion object {
@JvmStatic
@BeforeAll
fun beforeAll() {
with(CryptoPrice.logger) {
addHandler(ConsoleHandler().apply { level = Level.FINE })
level = Level.FINE
useParentHandlers = false
}
}
}
}