Added messageWithoutSensitiveData as extra field so that user can choose between them
This commit is contained in:
parent
20fe60d9f6
commit
ab0b676216
|
@ -37,23 +37,25 @@ open class MessageLogCollector(
|
||||||
|
|
||||||
// in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData
|
// in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData
|
||||||
open val messageLog: List<MessageLogEntry>
|
open val messageLog: List<MessageLogEntry>
|
||||||
// safe CPU cycles by only formatting and removing sensitive data if messageLog is really requested
|
// safe CPU cycles by only removing sensitive data if messageLog is really requested
|
||||||
get() = _messageLog.map { MessageLogEntry(it.type, it.context, it.messageTrace, createMessageForLog(it), it.error, it.parsedSegments, it.time) }
|
get() = _messageLog.map {
|
||||||
|
val message = createMessageForLog(it)
|
||||||
|
val messageWithoutSensitiveData = if (options.removeSensitiveDataFromMessageLog) {
|
||||||
|
safelyRemoveSensitiveDataFromMessage(message, it.context.bank)
|
||||||
|
} else {
|
||||||
|
message
|
||||||
|
}
|
||||||
|
|
||||||
private fun createMessageForLog(logEntry: MessageLogEntry): String {
|
MessageLogEntry(it.type, it.context, it.messageTrace, message, messageWithoutSensitiveData, it.error, it.parsedSegments, it.time)
|
||||||
val message = if (logEntry.type == MessageLogEntryType.Error) {
|
}
|
||||||
|
|
||||||
|
private fun createMessageForLog(logEntry: MessageLogEntry): String =
|
||||||
|
if (logEntry.type == MessageLogEntryType.Error) {
|
||||||
logEntry.message + (if (logEntry.error != null) NewLine + getStackTrace(logEntry.error!!) else "")
|
logEntry.message + (if (logEntry.error != null) NewLine + getStackTrace(logEntry.error!!) else "")
|
||||||
} else {
|
} else {
|
||||||
logEntry.message
|
logEntry.message
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (options.removeSensitiveDataFromMessageLog) {
|
|
||||||
safelyRemoveSensitiveDataFromMessage(message, logEntry.context.bank)
|
|
||||||
} else {
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
open fun addMessageLog(type: MessageLogEntryType, message: String, context: MessageContext, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
open fun addMessageLog(type: MessageLogEntryType, message: String, context: MessageContext, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
||||||
val messageTrace = createMessageTraceString(type, context)
|
val messageTrace = createMessageTraceString(type, context)
|
||||||
|
@ -76,7 +78,7 @@ open class MessageLogCollector(
|
||||||
|
|
||||||
protected open fun addMessageLogEntry(type: MessageLogEntryType, context: MessageContext, messageTrace: String, message: String, error: Throwable? = null, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
protected open fun addMessageLogEntry(type: MessageLogEntryType, context: MessageContext, messageTrace: String, message: String, error: Throwable? = null, parsedSegments: List<ReceivedSegment> = emptyList()) {
|
||||||
if (options.collectMessageLog || options.fireCallbackOnMessageLogs) {
|
if (options.collectMessageLog || options.fireCallbackOnMessageLogs) {
|
||||||
val newEntry = MessageLogEntry(type, context, messageTrace, message, error, parsedSegments)
|
val newEntry = MessageLogEntry(type, context, messageTrace, message, null, error, parsedSegments)
|
||||||
|
|
||||||
if (options.collectMessageLog) {
|
if (options.collectMessageLog) {
|
||||||
_messageLog.add(newEntry)
|
_messageLog.add(newEntry)
|
||||||
|
|
|
@ -11,6 +11,7 @@ open class MessageLogEntry(
|
||||||
open val context: MessageContext,
|
open val context: MessageContext,
|
||||||
open val messageTrace: String,
|
open val messageTrace: String,
|
||||||
open val message: String,
|
open val message: String,
|
||||||
|
open val messageWithoutSensitiveData: String? = null,
|
||||||
open val error: Throwable? = null,
|
open val error: Throwable? = null,
|
||||||
/**
|
/**
|
||||||
* Parsed received segments.
|
* Parsed received segments.
|
||||||
|
|
Loading…
Reference in New Issue