Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"jest": "29.7.0",
"jest-junit": "16.0.0",
"nodemon": "3.1.9",
"npm-check-updates": "17.1.18",
"npm-check-updates": "18.0.0",
"nyc": "17.1.0",
"parse-strings-in-object": "1.6.0",
"pre-commit": "1.2.2",
Expand Down
19 changes: 6 additions & 13 deletions src/lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
const { loggerFactory, LOG_LEVELS } = require('@mojaloop/sdk-standard-components').Logger
const { hostname } = require('node:os')
const os = require('node:os')

const createLogger = (conf = {}) => {
const {
context = {
hostname: hostname()
},
isJsonOutput = false
} = conf

return loggerFactory({ context, isJsonOutput })
}

const logger = createLogger() // global logger
const logger = loggerFactory({
context: 'TTK',
hostname: os.hostname(),
isJsonOutput: false
}) // global logger

module.exports = {
logger,
Expand Down
15 changes: 5 additions & 10 deletions src/lib/requestLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

'use strict'

const util = require('node:util')
const Logger = require('@mojaloop/central-services-logger')
const Logger = require('@mojaloop/central-services-logger').child({ context: 'TTK' })
const Config = require('./config')
const NotificationEmitter = require('./notificationEmitter')
const DBAdapter = require('./db/adapters/dbAdapter')
Expand Down Expand Up @@ -128,21 +127,17 @@ const logMessage = (verbosity, message, externalData = {}) => {
}
switch (verbosity) {
case 'debug':
Logger.debug(message)
if (data.additionalData !== undefined) Logger.debug(util.inspect(data.additionalData))
Logger.debug(message, data.additionalData)
break
case 'warn':
Logger.warn(message)
if (data.additionalData !== undefined) Logger.warn(util.inspect(data.additionalData))
Logger.warn(message, data.additionalData)
break
case 'error':
Logger.error(message)
if (data.additionalData !== undefined) Logger.error(util.inspect(data.additionalData))
Logger.error(message, data.additionalData)
break
case 'info':
default: {
Logger.info(message)
if (data.additionalData !== undefined) Logger.info(util.inspect(data.additionalData))
Logger.info(message, data.additionalData)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/test-outbound/TestCaseRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const SKIP_EMPTY_EXECUTION_ORDER = false // skip testCases without executionOrde
class TestCaseRunner {
constructor (config, logger) {
this.config = config
this.logger = logger || loggerFactory('TestCaseRunner')
this.logger = logger || loggerFactory('TTK')
}

async runAll ({
Expand Down
6 changes: 4 additions & 2 deletions src/lib/test-outbound/outbound-initiator.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ const processTestCase = async (
)
}
} catch (err) {
customLogger.logMessage('error', err.message)
customLogger.logMessage('error', err.message, { additionalData: err })
let resp
try {
resp = JSON.parse(err.message)
Expand Down Expand Up @@ -839,7 +839,9 @@ const sendRequest = (convertedRequest, successCallbackUrl, errorCallbackUrl, dfs
callbackHeaders = result.headers
}
customLogger.logMessage('info', 'Received error callback ' + errorCallbackUrl, { request: { headers: callbackHeaders, body: callbackBody }, notification: false })
return reject(new Error(JSON.stringify({ curlRequest, requestSent, transformedRequest, syncResponse, callback: { url: errorCallbackUrl, headers: callbackHeaders, body: callbackBody, originalHeaders, originalBody } })))
const error = new Error(JSON.stringify({ curlRequest, requestSent, transformedRequest, syncResponse, callback: { url: errorCallbackUrl, headers: callbackHeaders, body: callbackBody, originalHeaders, originalBody } }))
error.error = callbackBody
return reject(error)
})
}

Expand Down