diff --git a/backend/src/graphql/resolver/BalanceResolver.ts b/backend/src/graphql/resolver/BalanceResolver.ts index a702cc08f..8103e0cff 100644 --- a/backend/src/graphql/resolver/BalanceResolver.ts +++ b/backend/src/graphql/resolver/BalanceResolver.ts @@ -15,6 +15,7 @@ import { calculateDecay } from '@/util/decay' import { GdtResolver } from './GdtResolver' import { getLastTransaction } from './util/getLastTransaction' import { transactionLinkSummary } from './util/transactionLinkSummary' +import { DecayLoggingView } from '@/logging/DecayLogging.view' @Resolver() export class BalanceResolver { @@ -85,9 +86,9 @@ export class BalanceResolver { ) logger.info( 'calculatedDecay', - lastTransaction.balance, - lastTransaction.balanceDate, - calculatedDecay, + lastTransaction.balance.toString(), + lastTransaction.balanceDate.toISOString(), + new DecayLoggingView(calculatedDecay), ) // The final balance is reduced by the link amount withheld @@ -115,7 +116,7 @@ export class BalanceResolver { count, linkCount, }) - logger.info('new Balance', balance, balanceGDT, count, linkCount, newBalance) + logger.info('new Balance', balance.toString(), balanceGDT?.toString(), count, linkCount, newBalance.toString()) return newBalance } diff --git a/backend/src/logging/DecayLogging.view.ts b/backend/src/logging/DecayLogging.view.ts new file mode 100644 index 000000000..aef7c6da6 --- /dev/null +++ b/backend/src/logging/DecayLogging.view.ts @@ -0,0 +1,20 @@ +import { Decay } from '@/graphql/model/Decay' +import { AbstractLoggingView } from '@logging/AbstractLogging.view' + +export class DecayLoggingView extends AbstractLoggingView { + public constructor(private self: Decay) { + super() + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + public toJSON(): any { + return { + balance: this.decimalToString(this.self.balance), + decay: this.decimalToString(this.self.decay), + roundedDecay: this.decimalToString(this.self.roundedDecay), + start: this.dateToString(this.self.start), + end: this.dateToString(this.self.end), + duration: this.self.duration + } + } +}