Skip to content

Commit

Permalink
chore: handle non-object arguments for logger
Browse files Browse the repository at this point in the history
chore: add stats for gladly API call
Signed-off-by: Sai Sankeerth <[email protected]>
  • Loading branch information
Sai Sankeerth committed Jun 18, 2024
1 parent 6279c79 commit 4adb977
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/cdk/v2/destinations/gladly/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ steps:
headers: $.getHeaders(.destination)
}
const endpoint = $.getEndpoint(.destination) + "?" + $.getQueryParams($.context.payload);
const rawResponse = await $.httpGET(endpoint,requestOptions)
const reqStats = {metadata:.metadata, module: 'router',feature: "transformation", destType:"gladly",requestMethod:"get",endpointPath:"/api/v1/customer-profiles"}
const rawResponse = await $.httpGET(endpoint,requestOptions, reqStats)
const processedResponse = $.processAxiosResponse(rawResponse)
processedResponse
Expand Down
22 changes: 19 additions & 3 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,33 @@ const getLogMetadata = (metadata) => {
};
};

const formLogArgs = (args) => {
let msg = '';
let otherArgs = [];
args.forEach((arg) => {
if (typeof arg !== 'object') {
msg += ' ' + arg;
return;
}
otherArgs.push(arg);
});
return [msg, ...otherArgs];
};

/**
* Perform logging operation on logMethod passed
*
* **Good practices**:
* - Do not have more than one array args in logger
* @param {*} logMethod
* - instance method reference
* - The logger should implement all of debug/info/warn/error methods
* @param {*} args
* @param {*} logArgs
* - the arguments that needs to be passed to logger instance method
*/
const log = (logMethod, args) => {
const [message, logInfo, ...otherArgs] = args;
const log = (logMethod, logArgs) => {
const [message, ...args] = formLogArgs(logArgs);
const [logInfo, ...otherArgs] = args;
if (logInfo) {
const { metadata, ...otherLogInfoArgs } = logInfo;
if (Array.isArray(metadata)) {
Expand Down

0 comments on commit 4adb977

Please sign in to comment.