From 0c94386f55f40911ebb7530650783f0e83e7dc00 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner Date: Wed, 16 Jul 2025 22:12:08 +0200 Subject: [PATCH] introduce a method specific logger --- .../logic/interpretEncryptedTransferArgs.ts | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core/src/graphql/logic/interpretEncryptedTransferArgs.ts b/core/src/graphql/logic/interpretEncryptedTransferArgs.ts index 26036b350..b5b2f7f7a 100644 --- a/core/src/graphql/logic/interpretEncryptedTransferArgs.ts +++ b/core/src/graphql/logic/interpretEncryptedTransferArgs.ts @@ -9,33 +9,34 @@ import { LOG4JS_BASE_CATEGORY_NAME } from '../../config/const' const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.graphql.resolver.util.interpretEncryptedTransferArgs`) export const interpretEncryptedTransferArgs = async (args: EncryptedTransferArgs): Promise => { - logger.addContext('handshakeID', args.handshakeID) - logger.debug('interpretEncryptedTransferArgs()... args:', args) + const methodLogger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.graphql.resolver.util.interpretEncryptedTransferArgs-method`) + methodLogger.addContext('handshakeID', args.handshakeID) + methodLogger.debug('interpretEncryptedTransferArgs()... args:', args) // first find with args.publicKey the community 'requestingCom', which starts the request const requestingCom = await DbCommunity.findOneBy({ publicKey: Buffer.from(args.publicKey, 'hex') }) if (!requestingCom) { const errmsg = `unknown requesting community with publicKey ${args.publicKey}` - logger.error(errmsg) - logger.removeContext('handshakeID') + methodLogger.error(errmsg) + methodLogger.removeContext('handshakeID') throw new Error(errmsg) } if (!requestingCom.publicJwtKey) { const errmsg = `missing publicJwtKey of requesting community with publicKey ${args.publicKey}` - logger.error(errmsg) - logger.removeContext('handshakeID') + methodLogger.error(errmsg) + methodLogger.removeContext('handshakeID') throw new Error(errmsg) } - logger.debug(`found requestingCom:`, new CommunityLoggingView(requestingCom)) + methodLogger.debug(`found requestingCom:`, new CommunityLoggingView(requestingCom)) // verify the signing of args.jwt with homeCom.privateJwtKey and decrypt args.jwt with requestingCom.publicJwtKey const homeCom = await getHomeCommunity() const jwtPayload = await verifyAndDecrypt(args.handshakeID, args.jwt, homeCom!.privateJwtKey!, requestingCom.publicJwtKey) as JwtPayloadType if (!jwtPayload) { const errmsg = `invalid payload of community with publicKey ${args.publicKey}` - logger.error(errmsg) - logger.removeContext('handshakeID') + methodLogger.error(errmsg) + methodLogger.removeContext('handshakeID') throw new Error(errmsg) } - logger.debug('jwtPayload', jwtPayload) - logger.removeContext('handshakeID') + methodLogger.debug('jwtPayload', jwtPayload) + methodLogger.removeContext('handshakeID') return jwtPayload }