Added option to disable collection messageLog

This commit is contained in:
dankito 2024-08-23 13:02:10 +02:00
parent 9857a0565d
commit c0796cfc38
3 changed files with 22 additions and 5 deletions

View File

@ -3,6 +3,15 @@ package net.dankito.banking.fints.config
import net.dankito.banking.fints.model.ProductData
data class FinTsClientOptions(
/**
* If FinTS messages sent to and received from bank servers and errors should be collected. They are then accessible
* via [net.dankito.banking.fints.response.client.FinTsClientResponse.messageLog].
*
* Set to false by default.
*/
val collectMessageLog: Boolean = false,
/**
* If set to true then [net.dankito.banking.fints.callback.FinTsClientCallback.messageLogAdded] get fired when a
* FinTS message get sent to bank server, a FinTS message is received from bank server or an error occurred.

View File

@ -72,13 +72,17 @@ open class MessageLogCollector(
}
protected open fun addMessageLogEntry(type: MessageLogEntryType, context: MessageContext, messageTrace: String, message: String, error: Throwable? = null) {
val newEntry = MessageLogEntry(type, context, messageTrace, message, error)
if (options.collectMessageLog || options.fireCallbackOnMessageLogs) {
val newEntry = MessageLogEntry(type, context, messageTrace, message, error)
_messageLog.add(newEntry)
if (options.collectMessageLog) {
_messageLog.add(newEntry)
}
if (options.fireCallbackOnMessageLogs) {
// TODO: pretty print message
callback.messageLogAdded(newEntry)
if (options.fireCallbackOnMessageLogs) {
// TODO: pretty print message
callback.messageLogAdded(newEntry)
}
}
}

View File

@ -18,6 +18,10 @@ open class FinTsClientResponse(
open val isStrongAuthenticationRequired: Boolean,
open val tanRequired: TanResponse? = null,
/**
* Collected FinTS messages sent to and received from bank servers and error messages. Will only be available if
* [net.dankito.banking.fints.config.FinTsClientOptions.collectMessageLog] is set to true (is disabled by default).
*/
open val messageLog: List<MessageLogEntry>,
/**