diff --git a/benchmark/index.js b/benchmark/index.js index 919fa3c6de..f729baade6 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -16,7 +16,7 @@ const cdkV2Handler = require('../src/cdk/v2/handler'); const supportedDestinations = ['algolia', 'pinterest_tag']; -logger.info(); +logger.infow(); const command = new Commander.Command(); command @@ -52,10 +52,10 @@ const getTestData = (intgList, fileNameSuffixes) => { }), ); } catch (err) { - // logger.error( + // logger.errorw( // `Unable to load the data for: "${intg}" suffix: "${fileNameSuffix}"` // ); - // logger.error(`Raw error: "${err}"`); + // logger.errorw(`Raw error: "${err}"`); } }); }); @@ -69,8 +69,8 @@ const destinationsList = cmdOpts.destinations .split(',') .map((x) => x.trim()) .filter((x) => x !== ''); -logger.info('Destinations:', destinationsList, 'feature:', cmdOpts.feature); -logger.info(); +logger.infow('Destinations:', destinationsList, 'feature:', cmdOpts.feature); +logger.infow(); const destDataset = getTestData(destinationsList, ['_input', '']); const nativeDestHandlers = {}; @@ -99,9 +99,9 @@ async function initializeHandlers() { } async function runDataset(suitDesc, input, intg, params) { - logger.info('=========================================='); - logger.info(suitDesc); - logger.info('=========================================='); + logger.infow('=========================================='); + logger.infow(suitDesc); + logger.infow('=========================================='); const results = {}; const suite = new Benchmark(suitDesc, benchmarkType); @@ -113,7 +113,7 @@ async function runDataset(suitDesc, input, intg, params) { try { await handler(...args); } catch (err) { - // logger.info(err); + // logger.infow(err); // Do nothing } }); @@ -124,23 +124,23 @@ async function runDataset(suitDesc, input, intg, params) { results[result.end.name] = { stats: result.end.stats }; }) .on('complete', (result) => { - logger.info( + logger.infow( benchmarkType === 'Operations' ? 'Fastest: ' : 'Memory intensive: ', `"${result.end.name}"`, ); - logger.info(); + logger.infow(); Object.keys(results).forEach((impl) => { - logger.info(`"${impl}" - `, suite.formatStats(results[impl].stats)); + logger.infow(`"${impl}" - `, suite.formatStats(results[impl].stats)); if (result.end.name !== impl) { if (benchmarkType === 'Operations') { - logger.info( + logger.infow( `-> "${result.end.name}" is faster by ${( results[impl].stats.mean / result.end.stats.mean ).toFixed(1)} times to "${impl}"`, ); } else { - logger.info( + logger.infow( `-> "${result.end.name}" consumed ${( result.end.stats.mean / results[impl].stats.mean ).toFixed(1)} times memory compared to "${impl}"`, @@ -148,7 +148,7 @@ async function runDataset(suitDesc, input, intg, params) { } } - logger.info(); + logger.infow(); }); }); diff --git a/benchmark/metaLogger.js b/benchmark/metaLogger.js index 2af1f599c9..d4debb4976 100644 --- a/benchmark/metaLogger.js +++ b/benchmark/metaLogger.js @@ -6,13 +6,13 @@ logger.setLogLevel(Number.POSITIVE_INFINITY); const debug = (...args) => { logger.setLogLevel(logger.levelDebug); - logger.debug(...args); + logger.debugw(...args); logger.setLogLevel(Number.POSITIVE_INFINITY); }; const info = (...args) => { logger.setLogLevel(logger.levelInfo); - logger.info(...args); + logger.infow(...args); logger.setLogLevel(Number.POSITIVE_INFINITY); }; @@ -24,7 +24,7 @@ const warn = (...args) => { const error = (...args) => { logger.setLogLevel(logger.levelError); - logger.error(...args); + logger.errorw(...args); logger.setLogLevel(Number.POSITIVE_INFINITY); }; diff --git a/src/adapters/network.js b/src/adapters/network.js index b0bd14374e..25ac73dafb 100644 --- a/src/adapters/network.js +++ b/src/adapters/network.js @@ -5,7 +5,7 @@ const lodash = require('lodash'); const http = require('http'); const https = require('https'); const axios = require('axios'); -const log = require('../logger'); +const log = require('@rudderstack/integrations-lib/build/structured-logger'); const stats = require('../util/stats'); const { removeUndefinedValues } = require('../v0/util'); const { processAxiosResponse } = require('./utils/networkUtils'); diff --git a/src/cdk/v2/utils.ts b/src/cdk/v2/utils.ts index f9a5c66937..f1b77489f8 100644 --- a/src/cdk/v2/utils.ts +++ b/src/cdk/v2/utils.ts @@ -2,7 +2,7 @@ import path from 'path'; import fs from 'fs/promises'; import { WorkflowExecutionError, WorkflowCreationError } from '@rudderstack/workflow-engine'; import { PlatformError } from '@rudderstack/integrations-lib'; -import logger from '../../logger'; +import logger from '@rudderstack/integrations-lib/build/structured-logger'; import { generateErrorObject } from '../../v0/util'; import tags from '../../v0/util/tags'; import { CatchErr } from '../../util/types'; diff --git a/src/controllers/bulkUpload.ts b/src/controllers/bulkUpload.ts index 96216e3718..eb23e82b12 100644 --- a/src/controllers/bulkUpload.ts +++ b/src/controllers/bulkUpload.ts @@ -31,9 +31,9 @@ const getReqMetadata = (ctx) => { }; export const fileUpload = async (ctx) => { - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request to transformer:: /fileUpload route', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const getReqMetadataFileUpload = () => { try { @@ -69,17 +69,17 @@ export const fileUpload = async (ctx) => { }); } ctx.body = response; - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Response from transformer:: /fileUpload route', - JSON.stringify(ctx.body), + ctx.body, ); return ctx.body; }; export const pollStatus = async (ctx) => { - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request to transformer:: /pollStatus route', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const { destType }: ContextBodySimple = ctx.request.body; @@ -104,17 +104,17 @@ export const pollStatus = async (ctx) => { }); } ctx.body = response; - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request from transformer:: /pollStatus route', - JSON.stringify(ctx.body), + ctx.body, ); return ctx.body; }; export const getWarnJobStatus = async (ctx) => { - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request to transformer:: /getWarningJobs route', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const { destType }: ContextBodySimple = ctx.request.body; @@ -140,17 +140,17 @@ export const getWarnJobStatus = async (ctx) => { }); } ctx.body = response; - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request from transformer:: /getWarningJobs route', - JSON.stringify(ctx.body), + ctx.body, ); return ctx.body; }; export const getFailedJobStatus = async (ctx) => { - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request to transformer:: /getFailedJobs route', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const { destType }: ContextBodySimple = ctx.request.body; @@ -176,9 +176,9 @@ export const getFailedJobStatus = async (ctx) => { }); } ctx.body = response; - logger.debug( + logger.debugw( 'Native(Bulk-Upload): Request from transformer:: /getFailedJobs route', - JSON.stringify(ctx.body), + ctx.body, ); return ctx.body; }; diff --git a/src/controllers/delivery.ts b/src/controllers/delivery.ts index cb37cc149b..9ffcb2fa73 100644 --- a/src/controllers/delivery.ts +++ b/src/controllers/delivery.ts @@ -21,7 +21,7 @@ const NON_DETERMINABLE = 'Non-determinable'; export class DeliveryController { public static async deliverToDestination(ctx: Context) { - logger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body)); + logger.debug('Native(Delivery):: Request to transformer::', ctx.request.body); let deliveryResponse: DeliveryResponse; const requestMetadata = MiscService.getRequestMetadata(ctx); const deliveryRequest = ctx.request.body as ProxyDeliveryRequest; @@ -51,12 +51,12 @@ export class DeliveryController { ctx.body = { output: deliveryResponse }; ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status); - logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body)); + logger.debug('Native(Delivery):: Response from transformer::', ctx.body); return ctx; } public static async deliverToDestinationV1(ctx: Context) { - logger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body)); + logger.debug('Native(Delivery):: Request to transformer::', ctx.request.body); let deliveryResponse: DeliveriesResponse; const requestMetadata = MiscService.getRequestMetadata(ctx); const deliveryRequest = ctx.request.body as ProxyDeliveriesRequest; @@ -86,14 +86,14 @@ export class DeliveryController { ctx.body = { output: deliveryResponse }; ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status); - logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body)); + logger.debug('Native(Delivery):: Response from transformer::', ctx.body); return ctx; } public static async testDestinationDelivery(ctx: Context) { logger.debug( 'Native(Delivery-Test):: Request to transformer::', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const { destination }: { destination: string } = ctx.params; const { version }: { version: string } = ctx.params; @@ -112,7 +112,7 @@ export class DeliveryController { ); ctx.body = { output: response }; ControllerUtility.postProcess(ctx); - logger.debug('Native(Delivery-Test):: Response from transformer::', JSON.stringify(ctx.body)); + logger.debug('Native(Delivery-Test):: Response from transformer::', ctx.body); return ctx; } } diff --git a/src/controllers/destination.ts b/src/controllers/destination.ts index b22a09a7c5..bef6b381ce 100644 --- a/src/controllers/destination.ts +++ b/src/controllers/destination.ts @@ -21,7 +21,7 @@ export class DestinationController { const startTime = new Date(); logger.info( 'Native(Process-Transform):: Requst to transformer::', - JSON.stringify(ctx.request.body), + ctx.request.body, ); let resplist: ProcessorTransformationResponse[]; const requestMetadata = MiscService.getRequestMetadata(ctx); @@ -70,7 +70,7 @@ export class DestinationController { ControllerUtility.postProcess(ctx); logger.info( 'Native(Process-Transform):: Response from transformer::', - JSON.stringify(ctx.body), + ctx.body, ); stats.histogram('dest_transform_output_events', resplist.length, { destination, @@ -142,7 +142,7 @@ export class DestinationController { }); logger.info( 'Native(Router-Transform):: Response from transformer::', - JSON.stringify(ctx.body), + ctx.body, ); stats.timing('dest_transform_request_latency', startTime, { destination, @@ -156,7 +156,7 @@ export class DestinationController { public static batchProcess(ctx: Context) { logger.info( 'Native(Process-Transform-Batch):: Requst to transformer::', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const startTime = new Date(); const requestMetadata = MiscService.getRequestMetadata(ctx); @@ -191,7 +191,7 @@ export class DestinationController { ControllerUtility.postProcess(ctx); logger.info( 'Native(Process-Transform-Batch):: Response from transformer::', - JSON.stringify(ctx.body), + ctx.body, ); stats.timing('dest_transform_request_latency', startTime, { destination, diff --git a/src/controllers/obs.delivery.js b/src/controllers/obs.delivery.js index 4a93afe1dc..44a6f2a4c5 100644 --- a/src/controllers/obs.delivery.js +++ b/src/controllers/obs.delivery.js @@ -8,10 +8,10 @@ const match = require('match-json'); const jsonDiff = require('json-diff'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const networkHandlerFactory = require('../adapters/networkHandlerFactory'); const { getPayloadData } = require('../adapters/network'); const { generateErrorObject } = require('../v0/util'); -const logger = require('../logger'); const tags = require('../v0/util/tags'); const stats = require('../util/stats'); @@ -60,18 +60,18 @@ const DestProxyController = { destination, }); - logger.error(`[TransformerProxyTest] Destination request payload mismatch!`); - logger.error( + logger.errorw(`[TransformerProxyTest] Destination request payload mismatch!`); + logger.errorw( `[TransformerProxyTest] Delivery payload (router): ${JSON.stringify( routerDeliveryPayload, )}`, ); - logger.error( + logger.errorw( `[TransformerProxyTest] Destination request payload (router): ${JSON.stringify( routerDestReqPayload, )}`, ); - logger.error( + logger.errorw( `[TransformerProxyTest] Destination request payload (proxy): ${JSON.stringify( proxyDestReqPayload, )} `, @@ -79,7 +79,7 @@ const DestProxyController = { // Compute output difference const outputDiff = jsonDiff.diffString(routerDestReqPayload, proxyDestReqPayload); - logger.error( + logger.errorw( `[TransformerProxyTest] Destination request payload difference: ${outputDiff}`, ); response = { @@ -102,14 +102,14 @@ const DestProxyController = { [tags.TAG_NAMES.FEATURE]: tags.FEATURES.DATA_DELIVERY, }, false); response.message = `[TransformerProxyTest] Error occurred while testing proxy for destination ("${destination}"): "${err.message}"`; - logger.error(response.message); - logger.error(err); - logger.error( + logger.errorw(response.message); + logger.errorw(err); + logger.errorw( `[TransformerProxyTest] Delivery payload (router): ${JSON.stringify( routerDeliveryPayload, )}`, ); - logger.error( + logger.errorw( `[TransformerProxyTest] Destination request payload (router): ${JSON.stringify( routerDestReqPayload, )}`, diff --git a/src/controllers/regulation.ts b/src/controllers/regulation.ts index 158bec6635..a600c9ecf0 100644 --- a/src/controllers/regulation.ts +++ b/src/controllers/regulation.ts @@ -12,7 +12,7 @@ export class RegulationController { public static async deleteUsers(ctx: Context) { logger.debug( 'Native(Process-Transform):: Requst to transformer::', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const startTime = new Date(); let rudderDestInfo: any; @@ -23,7 +23,7 @@ export class RegulationController { rudderDestInfo = destInfoHeader; } } catch (error) { - logger.error(`Error while getting rudderDestInfo header value: ${error}`); + logger.errorw(`Error while getting rudderDestInfo header value: ${error}`); } const userDeletionRequests = ctx.request.body as UserDeletionRequest[]; diff --git a/src/controllers/source.ts b/src/controllers/source.ts index a17cb09d58..937ac7a2a9 100644 --- a/src/controllers/source.ts +++ b/src/controllers/source.ts @@ -9,7 +9,7 @@ export class SourceController { public static async sourceTransform(ctx: Context) { logger.debug( 'Native(Source-Transform):: Request to transformer::', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const requestMetadata = MiscService.getRequestMetadata(ctx); const events = ctx.request.body as object[]; @@ -36,7 +36,7 @@ export class SourceController { ControllerUtility.postProcess(ctx); logger.debug( 'Native(Source-Transform):: Response from transformer::', - JSON.stringify(ctx.body), + ctx.body, ); return ctx; } diff --git a/src/controllers/userTransform.ts b/src/controllers/userTransform.ts index c344bd072a..fa7f8bbb66 100644 --- a/src/controllers/userTransform.ts +++ b/src/controllers/userTransform.ts @@ -1,7 +1,7 @@ import { Context } from 'koa'; +import logger from '@rudderstack/integrations-lib/build/structured-logger'; import { ProcessorTransformationRequest, UserTransformationServiceResponse } from '../types/index'; import { UserTransformService } from '../services/userTransform'; -import logger from '../logger'; import { setupUserTransformHandler, extractLibraries, @@ -13,7 +13,7 @@ export class UserTransformController { public static async transform(ctx: Context) { logger.debug( '(User transform - router:/customTransform ):: Request to transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const events = ctx.request.body as ProcessorTransformationRequest[]; const processedRespone: UserTransformationServiceResponse = @@ -22,7 +22,7 @@ export class UserTransformController { ControllerUtility.postProcess(ctx, processedRespone.retryStatus); logger.debug( '(User transform - router:/customTransform ):: Response from transformer', - JSON.stringify(ctx.response.body), + ctx.response.body, ); return ctx; } @@ -30,7 +30,7 @@ export class UserTransformController { public static async testTransform(ctx: Context) { logger.debug( '(User transform - router:/transformation/test ):: Request to transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); const { events, trRevCode, libraryVersionIDs = [] } = ctx.request.body as any; const response = await UserTransformService.testTransformRoutine( @@ -42,7 +42,7 @@ export class UserTransformController { ControllerUtility.postProcess(ctx, response.status); logger.debug( '(User transform - router:/transformation/test ):: Response from transformer', - JSON.stringify(ctx.response.body), + ctx.response.body, ); return ctx; } @@ -50,7 +50,7 @@ export class UserTransformController { public static async testTransformLibrary(ctx: Context) { logger.debug( '(User transform - router:/transformationLibrary/test ):: Request to transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); try { const { code, language = 'javascript' } = ctx.request.body as any; @@ -65,7 +65,7 @@ export class UserTransformController { } logger.debug( '(User transform - router:/transformationLibrary/test ):: Response from transformer', - JSON.stringify(ctx.response.body), + ctx.response.body, ); return ctx; } @@ -73,7 +73,7 @@ export class UserTransformController { public static async testTransformSethandle(ctx: Context) { logger.debug( '(User transform - router:/transformation/sethandle ):: Request to transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); try { const { trRevCode, libraryVersionIDs = [] } = ctx.request.body as any; @@ -95,7 +95,7 @@ export class UserTransformController { } logger.debug( '(User transform - router:/transformation/sethandle ):: Response from transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); return ctx; } @@ -103,7 +103,7 @@ export class UserTransformController { public static async extractLibhandle(ctx: Context) { logger.debug( '(User transform - router:/extractLibs ):: Request to transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); try { const { @@ -133,7 +133,7 @@ export class UserTransformController { } logger.debug( '(User transform - router:/extractLibs ):: Response from transformer', - JSON.stringify(ctx.request.body), + ctx.request.body, ); return ctx; } diff --git a/src/index.ts b/src/index.ts index 5772f10765..37fa1787cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,13 +32,13 @@ app.use( addRequestSizeMiddleware(app); addSwaggerRoutes(app); -logger.info('Using new routes'); +logger.infow('Using new routes'); applicationRoutes(app); function finalFunction() { RedisDB.disconnect(); - logger.info('Redis client disconnected'); - logger.error(`Process (pid: ${process.pid}) was gracefully shutdown`); + logger.infow('Redis client disconnected'); + logger.errorw(`Process (pid: ${process.pid}) was gracefully shutdown`); logProcessInfo(); } @@ -59,15 +59,15 @@ if (clusterEnabled) { const server = app.listen(port); process.on('SIGTERM', () => { - logger.error(`SIGTERM signal received`); + logger.errorw(`SIGTERM signal received`); }); process.on('SIGINT', () => { - logger.error(`SIGINT signal received`); + logger.errorw(`SIGINT signal received`); }); process.on('SIGSEGV', () => { - logger.error(`SIGSEGV - JavaScript memory error occurred`); + logger.errorw(`SIGSEGV - JavaScript memory error occurred`); }); gracefulShutdown(server, { @@ -77,7 +77,7 @@ if (clusterEnabled) { finally: finalFunction, }); - logger.info(`App started. Listening on port: ${port}`); + logger.infow(`App started. Listening on port: ${port}`); } export default app; diff --git a/src/legacy/router.js b/src/legacy/router.js index f8deb3fe62..ecaba9697a 100644 --- a/src/legacy/router.js +++ b/src/legacy/router.js @@ -8,7 +8,7 @@ const lodash = require('lodash'); const fs = require('fs'); const path = require('path'); const { PlatformError } = require('@rudderstack/integrations-lib'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const stats = require('../util/stats'); const { SUPPORTED_VERSIONS, API_VERSION } = require('../routes/utils/constants'); const { client: errNotificationClient } = require('../util/errorNotifier'); @@ -140,7 +140,7 @@ async function handleDest(ctx, version, destination) { throw new PlatformError('Event is missing or in inappropriate format'); } const reqParams = ctx.request.query; - logger.debug(`[DT] Input events: ${JSON.stringify(events)}`); + logger.debugw(`[DT] Input events: ${JSON.stringify(events)}`); const metaTags = events && events.length > 0 && events[0].metadata ? getMetadata(events[0].metadata) : {}; @@ -184,7 +184,7 @@ async function handleDest(ctx, version, destination) { } return undefined; } catch (error) { - logger.error(error); + logger.errorw(error); let implementation = tags.IMPLEMENTATIONS.NATIVE; let errCtx = 'Processor Transformation'; @@ -223,7 +223,7 @@ async function handleDest(ctx, version, destination) { destination, ...metaTags, }); - logger.debug(`[DT] Output events: ${JSON.stringify(respList)}`); + logger.debugw(`[DT] Output events: ${JSON.stringify(respList)}`); stats.histogram('dest_transform_output_events', respList.length, { destination, version, @@ -276,7 +276,7 @@ async function handleValidation(ctx) { } } catch (error) { const errMessage = `Error occurred while validating : ${error}`; - logger.error(errMessage); + logger.errorw(errMessage); let status = 200; if (error instanceof RetryRequestError) { ctxStatusCode = error.statusCode; @@ -403,7 +403,7 @@ async function routerHandleDest(ctx) { }; }); } catch (error) { - logger.error(error); + logger.errorw(error); const errObj = generateErrorObject(error, defTags); @@ -523,7 +523,7 @@ if (startDestTransformer) { const startTime = new Date(); const events = ctx.request.body; const { processSessions } = ctx.query; - logger.debug(`[CT] Input events: ${JSON.stringify(events)}`); + logger.debugw(`[CT] Input events: ${JSON.stringify(events)}`); stats.histogram('user_transform_input_events', events.length, { processSessions, }); @@ -552,7 +552,7 @@ if (startDestTransformer) { } await Promise.all( Object.entries(groupedEvents).map(async ([dest, destEvents]) => { - logger.debug(`dest: ${dest}`); + logger.debugw(`dest: ${dest}`); const transformationVersionId = destEvents[0] && destEvents[0].destination && @@ -605,7 +605,7 @@ if (startDestTransformer) { }), ); } catch (error) { - logger.error(error); + logger.errorw(error); let status = 400; const errorString = error.toString(); if (error instanceof RetryRequestError) { @@ -628,7 +628,7 @@ if (startDestTransformer) { } } else { const errorMessage = 'Transformation VersionID not found'; - logger.error(`[CT] ${errorMessage}`); + logger.errorw(`[CT] ${errorMessage}`); transformedEvents.push({ statusCode: 400, error: errorMessage, @@ -642,7 +642,7 @@ if (startDestTransformer) { } }), ); - logger.debug(`[CT] Output events: ${JSON.stringify(transformedEvents)}`); + logger.debugw(`[CT] Output events: ${JSON.stringify(transformedEvents)}`); ctx.body = transformedEvents; ctx.status = ctxStatusCode; ctx.set('apiVersion', API_VERSION); @@ -669,7 +669,7 @@ if (transformerTestModeEnabled) { throw new Error('Invalid request. Missing events'); } - logger.debug(`[CT] Test Input Events: ${JSON.stringify(events)}`); + logger.debugw(`[CT] Test Input Events: ${JSON.stringify(events)}`); trRevCode.versionId = 'testVersionId'; const res = await userTransformHandler()( events, @@ -678,7 +678,7 @@ if (transformerTestModeEnabled) { trRevCode, true, ); - logger.debug(`[CT] Test Output Events: ${JSON.stringify(res.transformedEvents)}`); + logger.debugw(`[CT] Test Output Events: ${JSON.stringify(res.transformedEvents)}`); ctx.body = res; } catch (error) { ctx.status = error.statusCode || 400; @@ -714,7 +714,7 @@ if (transformerTestModeEnabled) { throw new Error('Invalid Request. Missing parameters in transformation code block'); } - logger.debug(`[CT] Setting up a transformation ${testName}`); + logger.debugw(`[CT] Setting up a transformation ${testName}`); if (!trRevCode.versionId) { trRevCode.versionId = 'testVersionId'; } @@ -722,7 +722,7 @@ if (transformerTestModeEnabled) { trRevCode.workspaceId = 'workspaceId'; } const res = await setupUserTransformHandler(libraryVersionIDs, trRevCode); - logger.debug(`[CT] Finished setting up transformation: ${testName}`); + logger.debugw(`[CT] Finished setting up transformation: ${testName}`); ctx.body = res; } catch (error) { ctx.status = 400; @@ -743,7 +743,7 @@ async function handleSource(ctx, version, source) { const sourceHandler = getSourceHandler(version, source); const events = ctx.request.body; - logger.debug(`[ST] Input source events: ${JSON.stringify(events)}`); + logger.debugw(`[ST] Input source events: ${JSON.stringify(events)}`); stats.counter('source_transform_input_events', events.length, { source, version, @@ -767,7 +767,7 @@ async function handleSource(ctx, version, source) { respList.push({ output: { batch: [respEvents] } }); } } catch (error) { - logger.error(error); + logger.errorw(error); // TODO: Update the data contact for source transformation // and then send the following additional information @@ -804,7 +804,7 @@ async function handleSource(ctx, version, source) { } }), ); - logger.debug(`[ST] Output source events: ${JSON.stringify(respList)}`); + logger.debugw(`[ST] Output source events: ${JSON.stringify(respList)}`); stats.increment('source_transform_output_events', respList.length, { source, version, @@ -874,8 +874,8 @@ async function handleProxyRequest(destination, ctx) { destination, }); } catch (err) { - logger.error('Error occurred while completing proxy request:'); - logger.error(err); + logger.errorw('Error occurred while completing proxy request:'); + logger.errorw(err); const errObj = generateErrorObject( err, @@ -1170,7 +1170,7 @@ const handleDeletionOfUsers = async (ctx) => { return destInfoHeader; } } catch (error) { - logger.error(`Error while getting rudderDestInfo header value: ${error}`); + logger.errorw(`Error while getting rudderDestInfo header value: ${error}`); } return {}; }; @@ -1220,7 +1220,7 @@ const handleDeletionOfUsers = async (ctx) => { }; respList.push(resp); - logger.error(`Error Response List: ${JSON.stringify(respList, null, 2)}`); + logger.errorw(`Error Response List: ${JSON.stringify(respList, null, 2)}`); errNotificationClient.notify(error, 'User Deletion', { ...resp, diff --git a/src/routerUtils.js b/src/routerUtils.js index ff9dd4b6f8..a8cb30b160 100644 --- a/src/routerUtils.js +++ b/src/routerUtils.js @@ -1,6 +1,6 @@ /* eslint-disable global-require */ /* eslint-disable import/no-dynamic-require */ -const logger = require('./logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const { proxyRequest } = require('./adapters/network'); const { nodeSysErrorToStatus } = require('./adapters/utils/networkUtils'); @@ -21,7 +21,7 @@ const userTransformHandler = () => { async function sendToDestination(destination, payload) { let parsedResponse; - logger.info('Request recieved for destination', destination); + logger.infow('Request recieved for destination', destination); const resp = await proxyRequest(payload); if (resp.success) { diff --git a/src/routes/index.ts b/src/routes/index.ts index d77584bea3..ac982b022c 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -4,6 +4,7 @@ import { existsSync, readFileSync } from 'fs'; import dotenv from 'dotenv'; import { koaSwagger } from 'koa2-swagger-ui'; import path from 'path'; +import logger from '@rudderstack/integrations-lib/build/structured-logger'; import userTransformRoutes from './userTransform'; import bulkUploadRoutes from './bulkUpload'; import proxyRoutes from './delivery'; @@ -12,7 +13,6 @@ import miscRoutes from './misc'; import sourceRoutes from './source'; import testEventRoutes from './testEvents'; import { trackingPlanRoutes } from './trackingPlan'; -import logger from '../logger'; import { isNotEmpty } from '../v0/util'; dotenv.config(); @@ -43,16 +43,16 @@ export function addSwaggerRoutes(app: Koa) { }); if (isNotEmpty(rawContent)) { const spec = JSON.parse(rawContent); - logger.info('Transformer: Swagger route loading'); + logger.infow('Transformer: Swagger route loading'); router.get( '/docs', koaSwagger({ routePrefix: false, swaggerOptions: { spec, deepLinking: true } }), ); - logger.info('Transformer: Swagger route loaded'); + logger.infow('Transformer: Swagger route loaded'); app.use(router.routes()); } } else { - logger.error('Swagger file does not exist!'); + logger.errorw('Swagger file does not exist!'); } } catch (err) { logger.error('Error while loading swagger file', err); diff --git a/src/routes/metricsRouter.js b/src/routes/metricsRouter.js index 757d88edde..3d740e9143 100644 --- a/src/routes/metricsRouter.js +++ b/src/routes/metricsRouter.js @@ -1,5 +1,5 @@ const KoaRouter = require('@koa/router'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const stats = require('../util/stats'); const metricsRouter = new KoaRouter(); @@ -11,7 +11,7 @@ if (enableStats) { try { await stats.metricsController(ctx); } catch (error) { - logger.error(error); + logger.errorw(error); ctx.status = 400; ctx.body = error.message; } diff --git a/src/services/comparator.ts b/src/services/comparator.ts index d1e085b4bd..5dce1eacea 100644 --- a/src/services/comparator.ts +++ b/src/services/comparator.ts @@ -1,4 +1,5 @@ /* eslint-disable class-methods-use-this */ +import logger from '@rudderstack/integrations-lib/build/structured-logger'; import { DestinationService } from '../interfaces/DestinationService'; import { DeliveriesResponse, @@ -16,7 +17,6 @@ import { } from '../types'; import tags from '../v0/util/tags'; import stats from '../util/stats'; -import logger from '../logger'; import { CommonUtils } from '../util/common'; const NS_PER_SEC = 1e9; @@ -90,17 +90,17 @@ export class ComparatorService implements DestinationService { )}`, ); - // logger.error( + // logger.errorw( // `[LIVE_COMPARE_TEST] failed for destinationId=${destinationId}, destType=${destination}, feature=${feature}, diff=${JSON.stringify( // objectDiff, // )}`, // ); - // logger.error( + // logger.errorw( // `[LIVE_COMPARE_TEST] failed for destinationId=${destinationId}, destType=${destination}, feature=${feature}, input=${JSON.stringify( // events[0], // )}`, // ); - // logger.error( + // logger.errorw( // `[LIVE_COMPARE_TEST] failed for destinationId=${destinationId}, destType=${destination}, feature=${feature}, results=${JSON.stringify( // { // primaryResult: primaryResplist[index], @@ -377,7 +377,7 @@ export class ComparatorService implements DestinationService { requestMetadata, version, ); - logger.error('[LIVE_COMPARE_TEST] not implemented for delivery routine'); + logger.errorw('[LIVE_COMPARE_TEST] not implemented for delivery routine'); return primaryResplist; } diff --git a/src/services/delivertTest/deliveryTest.ts b/src/services/delivertTest/deliveryTest.ts index 2f5db183e5..e14fc618ee 100644 --- a/src/services/delivertTest/deliveryTest.ts +++ b/src/services/delivertTest/deliveryTest.ts @@ -1,10 +1,10 @@ import match from 'match-json'; import jsonDiff from 'json-diff'; +import logger from '@rudderstack/integrations-lib/build/structured-logger'; import networkHandlerFactory from '../../adapters/networkHandlerFactory'; import { getPayloadData } from '../../adapters/network'; import { generateErrorObject } from '../../v0/util'; import stats from '../../util/stats'; -import logger from '../../logger'; import tags from '../../v0/util/tags'; export class DeliveryTestService { @@ -48,26 +48,26 @@ export class DeliveryTestService { destination, }); - logger.error(`[TransformerProxyTest] Destination request payload mismatch!`); - logger.error( - `[TransformerProxyTest] Delivery payload (router): ${JSON.stringify( - routerDeliveryPayload, + logger.errorw(`[TransformerProxyTest] Destination request payload mismatch!`); + logger.errorw( + `[TransformerProxyTest] Delivery payload (router): ${ + routerDeliveryPayload} )}`, ); - logger.error( - `[TransformerProxyTest] Destination request payload (router): ${JSON.stringify( - routerDestReqPayload, - )}`, + logger.errorw( + `[TransformerProxyTest] Destination request payload (router): + ${routerDestReqPayload} + }`, ); - logger.error( - `[TransformerProxyTest] Destination request payload (proxy): ${JSON.stringify( - proxyDestReqPayload, + logger.errorw( + `[TransformerProxyTest] Destination request payload (proxy): ${ + proxyDestReqPayload} )} `, ); // Compute output difference const outputDiff = jsonDiff.diffString(routerDestReqPayload, proxyDestReqPayload); - logger.error( + logger.errorw( `[TransformerProxyTest] Destination request payload difference: ${outputDiff}`, ); response = { @@ -90,17 +90,17 @@ export class DeliveryTestService { [tags.TAG_NAMES.FEATURE]: tags.FEATURES.DATA_DELIVERY, }); response.message = `[TransformerProxyTest] Error occurred while testing proxy for destination ("${destination}"): "${err.message}"`; - logger.error(response.message); - logger.error(err); - logger.error( - `[TransformerProxyTest] Delivery payload (router): ${JSON.stringify( - routerDeliveryPayload, - )}`, + logger.errorw(response.message); + logger.errorw(err); + logger.errorw( + `[TransformerProxyTest] Delivery payload (router): + ${routerDeliveryPayload}, + }`, ); - logger.error( - `[TransformerProxyTest] Destination request payload (router): ${JSON.stringify( - routerDestReqPayload, - )}`, + logger.errorw( + `[TransformerProxyTest] Destination request payload (router): ${ + routerDestReqPayload + }`, ); } return response; diff --git a/src/services/profile.ts b/src/services/profile.ts index 8351d476f7..74419d0f86 100644 --- a/src/services/profile.ts +++ b/src/services/profile.ts @@ -17,8 +17,8 @@ const intervalBytes = parseInt(process.env.PROF_INTERVAL_BYTES || '524288', 10); // The maximum stack depth for samples collected. const stackDepth = parseInt(process.env.PROF_STACK_DEPTH || '64', 10); -logger.info(`Stack Depth set: ${stackDepth}`); -logger.info(`Interval Bytes set: ${intervalBytes}`); +logger.infow(`Stack Depth set: ${stackDepth}`); +logger.infow(`Interval Bytes set: ${intervalBytes}`); heap.start(intervalBytes, stackDepth); @@ -82,7 +82,7 @@ export class ProfileService { try { const supportedCloudProvidersForDumpStorage = ['aws']; const shouldGenerateLocally = !credBucketDetails.sendTo; - logger.info('Before Heapsnapshot converted into a readable stream'); + logger.infow('Before Heapsnapshot converted into a readable stream'); let fileName = ''; // eslint-disable-next-line no-param-reassign format = 'pb.gz'; @@ -97,18 +97,18 @@ export class ProfileService { snapshotReadableStream = await pprof.encode(profile); } - logger.info('Heapsnapshot into a buffer'); + logger.infow('Heapsnapshot into a buffer'); fileName = `heap_${moment.utc().format('YYYY-MM-DD_HH:mm:ss.sss')}.${format}`; let data; if (shouldGenerateLocally) { - logger.info('Before pipeline'); + logger.infow('Before pipeline'); try { await writeFileProm(fileName, snapshotReadableStream); } catch (error: CatchErr) { - logger.error('Error occurred:', error); + logger.errorw('Error occurred:', error); throw new Error(error); } - logger.info('After pipeline'); + logger.infow('After pipeline'); } else if (credBucketDetails.sendTo) { if (credBucketDetails.sendTo === 'aws') { data = await this.uploadToAWS(credBucketDetails, fileName, snapshotReadableStream); @@ -121,7 +121,7 @@ export class ProfileService { } } // snapshotReadableStream.destroy(); - logger.info('Success', data); + logger.infow('Success', data); return { success: true, message: `Generated ${ @@ -129,7 +129,7 @@ export class ProfileService { } with filename: ${fileName}`, }; } catch (error: CatchErr) { - logger.error(error); + logger.errorw(error); return { success: false, message: error.message, diff --git a/src/services/trackingPlan.ts b/src/services/trackingPlan.ts index 883293e5f7..9f7554f133 100644 --- a/src/services/trackingPlan.ts +++ b/src/services/trackingPlan.ts @@ -44,7 +44,7 @@ export class TrackingPlanservice { } } catch (error) { const errMessage = `Error occurred while validating : ${error}`; - logger.error(errMessage); + logger.errorw(errMessage); let status = 200; if (error instanceof RetryRequestError) { ctxStatusCode = error.statusCode; diff --git a/src/services/userTransform.ts b/src/services/userTransform.ts index d1a358fefd..a5d93683f4 100644 --- a/src/services/userTransform.ts +++ b/src/services/userTransform.ts @@ -76,7 +76,7 @@ export class UserTransformService { if (!transformationVersionId) { const errorMessage = 'Transformation VersionID not found'; - logger.error(`[CT] ${errorMessage}`); + logger.errorw(`[CT] ${errorMessage}`); transformedEvents.push({ statusCode: 400, error: errorMessage, @@ -141,7 +141,7 @@ export class UserTransformService { transformedEvents.push(...transformedEventsWithMetadata); } catch (error: CatchErr) { - logger.error(error); + logger.errorw(error); let status = 400; const errorString = error.toString(); if (error instanceof RetryRequestError) { @@ -198,7 +198,7 @@ export class UserTransformService { throw new Error('Invalid request. Missing events'); } - logger.debug(`[CT] Test Input Events: ${JSON.stringify(events)}`); + logger.debugw(`[CT] Test Input Events: ${JSON.stringify(events)}`); // eslint-disable-next-line no-param-reassign trRevCode.versionId = 'testVersionId'; response.body = await userTransformHandler()( @@ -208,7 +208,7 @@ export class UserTransformService { trRevCode, true, ); - logger.debug(`[CT] Test Output Events: ${JSON.stringify(response.body.transformedEvents)}`); + logger.debugw(`[CT] Test Output Events: ${JSON.stringify(response.body.transformedEvents)}`); response.status = 200; } catch (error: CatchErr) { response.status = 400; diff --git a/src/util/cluster.js b/src/util/cluster.js index 5012bda324..e5130c69bd 100644 --- a/src/util/cluster.js +++ b/src/util/cluster.js @@ -1,6 +1,6 @@ const cluster = require('cluster'); const gracefulShutdown = require('http-graceful-shutdown'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const { logProcessInfo } = require('./utils'); const { RedisDB } = require('./redis/redisConnector'); @@ -8,11 +8,11 @@ const numWorkers = parseInt(process.env.NUM_PROCS || '1', 10); const metricsPort = parseInt(process.env.METRICS_PORT || '9091', 10); function finalFunction() { - logger.info('Process exit event received'); + logger.infow('Process exit event received'); RedisDB.disconnect(); - logger.info('Redis client disconnected'); + logger.infow('Redis client disconnected'); - logger.error(`Worker (pid: ${process.pid}) was gracefully shutdown`); + logger.errorw(`Worker (pid: ${process.pid}) was gracefully shutdown`); logProcessInfo(); } @@ -21,13 +21,13 @@ function finalFunction() { function shutdownWorkers() { Object.values(cluster.workers).forEach((worker) => { process.kill(worker.process.pid); - logger.error(`Sent kill signal to worker ${worker.id} (pid: ${worker.process.pid})`); + logger.errorw(`Sent kill signal to worker ${worker.id} (pid: ${worker.process.pid})`); }); } function start(port, app, metricsApp) { if (cluster.isMaster) { - logger.info(`Master (pid: ${process.pid}) has started`); + logger.infow(`Master (pid: ${process.pid}) has started`); // HTTP server for exposing metrics if (process.env.STATS_CLIENT === 'prometheus') { @@ -46,15 +46,15 @@ function start(port, app, metricsApp) { } cluster.on('online', (worker) => { - logger.info(`Worker (pid: ${worker.process.pid}) is online`); + logger.infow(`Worker (pid: ${worker.process.pid}) is online`); // To provide caching at pod-level }); let isShuttingDown = false; cluster.on('exit', (worker) => { if (!isShuttingDown) { - logger.error(`Worker (pid: ${worker.process.pid}) died`); - logger.error(`Killing other workers to avoid any side effects of the dead worker`); + logger.errorw(`Worker (pid: ${worker.process.pid}) died`); + logger.errorw(`Killing other workers to avoid any side effects of the dead worker`); logProcessInfo(); isShuttingDown = true; shutdownWorkers(); @@ -62,21 +62,21 @@ function start(port, app, metricsApp) { }); process.on('SIGTERM', () => { - logger.error('SIGTERM signal received. Closing workers...'); + logger.errorw('SIGTERM signal received. Closing workers...'); logProcessInfo(); isShuttingDown = true; shutdownWorkers(); }); process.on('SIGINT', () => { - logger.error('SIGINT signal received. Closing workers...'); + logger.errorw('SIGINT signal received. Closing workers...'); logProcessInfo(); isShuttingDown = true; shutdownWorkers(); }); process.on('SIGSEGV', () => { - logger.error('SIGSEGV - JavaScript memory error occurred. Closing workers...'); + logger.errorw('SIGSEGV - JavaScript memory error occurred. Closing workers...'); logProcessInfo(); isShuttingDown = true; shutdownWorkers(); @@ -91,19 +91,19 @@ function start(port, app, metricsApp) { }); process.on('SIGTERM', () => { - logger.error(`SIGTERM signal received in the worker`); + logger.errorw(`SIGTERM signal received in the worker`); }); process.on('SIGINT', () => { - logger.error(`SIGINT signal received in the worker`); + logger.errorw(`SIGINT signal received in the worker`); }); process.on('SIGSEGV', () => { - logger.error(`SIGSEGV - JavaScript memory error occurred in the worker`); + logger.errorw(`SIGSEGV - JavaScript memory error occurred in the worker`); }); - logger.info(`Worker (pid: ${process.pid}) has started`); - logger.info(`App started. Listening on port: ${port}`); + logger.infow(`Worker (pid: ${process.pid}) has started`); + logger.infow(`App started. Listening on port: ${port}`); } } diff --git a/src/util/customTransformer-v1.js b/src/util/customTransformer-v1.js index 60f8e493fa..192bad5dcb 100644 --- a/src/util/customTransformer-v1.js +++ b/src/util/customTransformer-v1.js @@ -2,7 +2,7 @@ const ivm = require('isolated-vm'); const { getFactory } = require('./ivmFactory'); const { getMetadata, getTransformationMetadata } = require('../v0/util'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const stats = require('./stats'); const userTransformTimeout = parseInt(process.env.USER_TRANSFORM_TIMEOUT || '600000', 10); @@ -66,7 +66,7 @@ async function userTransformHandlerV1( testMode, ); - logger.debug(`Creating IsolateVM`); + logger.debugw(`Creating IsolateVM`); const isolatevm = await isolatevmFactory.create(); const invokeTime = new Date(); @@ -78,11 +78,11 @@ async function userTransformHandlerV1( transformedEvents = await transform(isolatevm, events); logs = isolatevm.logs; } catch (err) { - logger.error(`Error encountered while executing transformation: ${err.message}`); + logger.errorw(`Error encountered while executing transformation: ${err.message}`); transformationError = err; throw err; } finally { - logger.debug(`Destroying IsolateVM`); + logger.debugw(`Destroying IsolateVM`); isolatevmFactory.destroy(isolatevm); // send the observability stats const tags = { diff --git a/src/util/customTransforrmationsStore-v1.js b/src/util/customTransforrmationsStore-v1.js index 3263049b6f..fcee82eba9 100644 --- a/src/util/customTransforrmationsStore-v1.js +++ b/src/util/customTransforrmationsStore-v1.js @@ -1,5 +1,5 @@ const { fetchWithProxy } = require('./fetch'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const { responseStatusHandler } = require('./utils'); const stats = require('./stats'); @@ -35,7 +35,7 @@ async function getTransformationCodeV1(versionId) { transformationCache[versionId] = myJson; return myJson; } catch (error) { - logger.error(error); + logger.errorw(error); stats.increment('get_transformation_code', { success: 'false', ...tags }); throw error; } @@ -60,7 +60,7 @@ async function getLibraryCodeV1(versionId) { libraryCache[versionId] = myJson; return myJson; } catch (error) { - logger.error(error); + logger.errorw(error); stats.increment('get_libraries_code', { success: 'false', ...tags }); throw error; } @@ -87,7 +87,7 @@ async function getRudderLibByImportName(importName) { rudderLibraryCache[importName] = myJson; return myJson; } catch (error) { - logger.error(error); + logger.errorw(error); stats.increment('get_libraries_code', { success: 'false', ...tags }); throw error; } diff --git a/src/util/customTransforrmationsStore.js b/src/util/customTransforrmationsStore.js index 08d417c07c..3a13e829e8 100644 --- a/src/util/customTransforrmationsStore.js +++ b/src/util/customTransforrmationsStore.js @@ -1,6 +1,6 @@ const NodeCache = require('node-cache'); const { fetchWithProxy } = require('./fetch'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const { responseStatusHandler } = require('./utils'); const stats = require('./stats'); @@ -28,7 +28,7 @@ async function getTransformationCode(versionId) { myCache.set(versionId, myJson); return myJson; } catch (error) { - logger.error(error); + logger.errorw(error); stats.increment('get_transformation_code', { versionId, success: 'false' }); throw error; } diff --git a/src/util/errorNotifier/bugsnag.js b/src/util/errorNotifier/bugsnag.js index ef01c58730..c534620742 100644 --- a/src/util/errorNotifier/bugsnag.js +++ b/src/util/errorNotifier/bugsnag.js @@ -76,7 +76,7 @@ function init() { }, }); } else { - logger.error(`Invalid Bugsnag API key: ${apiKey}`); + logger.errorw(`Invalid Bugsnag API key: ${apiKey}`); } } diff --git a/src/util/errorNotifier/default.js b/src/util/errorNotifier/default.js index 28557a22f2..329b197464 100644 --- a/src/util/errorNotifier/default.js +++ b/src/util/errorNotifier/default.js @@ -3,7 +3,7 @@ const logger = require('../../logger'); function init() {} function notify(err, context, metadata) { - logger.error(err, context, metadata); + logger.errorw(err, context, metadata); } module.exports = { diff --git a/src/util/eventValidation.js b/src/util/eventValidation.js index 68d895dcc5..bd2b4e9a5c 100644 --- a/src/util/eventValidation.js +++ b/src/util/eventValidation.js @@ -7,7 +7,7 @@ const addFormats = require('ajv-formats'); const NodeCache = require('node-cache'); const hash = require('object-hash'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const trackingPlan = require('./trackingPlan'); const SECONDS_IN_DAY = 60 * 60 * 24 * 1; @@ -241,7 +241,7 @@ async function validate(event) { }); return validationErrors; } catch (error) { - logger.error(`TP event validation error: ${error.message}`); + logger.errorw(`TP event validation error: ${error.message}`); throw error; } } @@ -257,7 +257,7 @@ function handleValidationErrors(validationErrors, metadata, curDropEvent, curVio const violationsByType = new Set(validationErrors.map((err) => err.type)); const handleUnknownOption = (value, key) => { - logger.error( + logger.errorw( `Unknown option ${value} in ${key} for destId ${destinationId}, destType ${destinationType}`, ); }; @@ -377,7 +377,7 @@ async function handleValidation(event) { validationErrors, }; } catch (error) { - logger.error(`TP handle validation error: ${error.message}`); + logger.errorw(`TP handle validation error: ${error.message}`); throw error; } } diff --git a/src/util/ivmFactory.js b/src/util/ivmFactory.js index 2ab5f9548a..c1948d0b47 100644 --- a/src/util/ivmFactory.js +++ b/src/util/ivmFactory.js @@ -4,7 +4,7 @@ const _ = require('lodash'); const { getLibraryCodeV1, getRudderLibByImportName } = require('./customTransforrmationsStore-v1'); const { extractStackTraceUptoLastSubstringMatch } = require('./utils'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const stats = require('./stats'); const { fetchWithDnsWrapper } = require('./utils'); diff --git a/src/util/openfaas/index.js b/src/util/openfaas/index.js index 878fa706d9..8b6bb479e3 100644 --- a/src/util/openfaas/index.js +++ b/src/util/openfaas/index.js @@ -73,7 +73,7 @@ const awaitFunctionReadiness = async ( resolve(true); } catch (error) { - logger.error(`Error while waiting for function ${functionName} to be ready: ${error}`); + logger.errorw(`Error while waiting for function ${functionName} to be ready: ${error}`); resolve(error.message); } }); @@ -124,7 +124,7 @@ const deployFaasFunction = async ( trMetadata = {}, ) => { try { - logger.debug('[Faas] Deploying a faas function'); + logger.debugw('[Faas] Deploying a faas function'); let envProcess = 'python index.py'; const lvidsString = libraryVersionIDs.join(','); @@ -181,9 +181,9 @@ const deployFaasFunction = async ( }; await deployFunction(payload); - logger.debug('[Faas] Deployed a faas function'); + logger.debugw('[Faas] Deployed a faas function'); } catch (error) { - logger.error(`[Faas] Error while deploying ${functionName}: ${error.message}`); + logger.errorw(`[Faas] Error while deploying ${functionName}: ${error.message}`); // To handle concurrent create requests, // throw retry error if deployment or service already exists so that request can be retried if ( @@ -207,7 +207,7 @@ async function setupFaasFunction( ) { try { if (!testMode && isFunctionDeployed(functionName)) { - logger.debug(`[Faas] Function ${functionName} already deployed`); + logger.debugw(`[Faas] Function ${functionName} already deployed`); return; } // deploy faas function @@ -224,9 +224,9 @@ async function setupFaasFunction( await awaitFunctionReadiness(functionName); setFunctionInCache(functionName); - logger.debug(`[Faas] Finished deploying faas function ${functionName}`); + logger.debugw(`[Faas] Finished deploying faas function ${functionName}`); } catch (error) { - logger.error(`[Faas] Error while setting function ${functionName}: ${error.message}`); + logger.errorw(`[Faas] Error while setting function ${functionName}: ${error.message}`); throw error; } } @@ -239,7 +239,7 @@ const executeFaasFunction = async ( testMode, trMetadata = {}, ) => { - logger.debug(`Executing faas function: ${name}`); + logger.debugw(`Executing faas function: ${name}`); const startTime = new Date(); let errorRaised; @@ -248,7 +248,7 @@ const executeFaasFunction = async ( if (testMode) await awaitFunctionReadiness(name); return await invokeFunction(name, events); } catch (error) { - logger.error(`Error while invoking ${name}: ${error.message}`); + logger.errorw(`Error while invoking ${name}: ${error.message}`); errorRaised = error; if (error.statusCode === 404 && error.message.includes(`error finding function ${name}`)) { @@ -274,7 +274,7 @@ const executeFaasFunction = async ( // delete the function created, if it's called as part of testMode if (testMode) { deleteFunction(name).catch((err) => - logger.error(`[Faas] Error while deleting ${name}: ${err.message}`), + logger.errorw(`[Faas] Error while deleting ${name}: ${err.message}`), ); } diff --git a/src/util/prometheus.js b/src/util/prometheus.js index d7ba3b7c61..60039e78a8 100644 --- a/src/util/prometheus.js +++ b/src/util/prometheus.js @@ -1,5 +1,5 @@ const prometheusClient = require('prom-client'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const clusterEnabled = process.env.CLUSTER_ENABLED !== 'false'; const instanceID = process.env.INSTANCE_ID || 'localhost'; @@ -98,7 +98,7 @@ class Prometheus { } metric.observe(tags, value); } catch (e) { - logger.error(`Prometheus: Summary metric ${name} failed with error ${e}`); + logger.errorw(`Prometheus: Summary metric ${name} failed with error ${e}`); } } @@ -113,7 +113,7 @@ class Prometheus { } metric.observe(tags, (new Date() - start) / 1000); } catch (e) { - logger.error(`Prometheus: Timing metric ${name} failed with error ${e}`); + logger.errorw(`Prometheus: Timing metric ${name} failed with error ${e}`); } } @@ -128,7 +128,7 @@ class Prometheus { } metric.observe(tags, value); } catch (e) { - logger.error(`Prometheus: Histogram metric ${name} failed with error ${e}`); + logger.errorw(`Prometheus: Histogram metric ${name} failed with error ${e}`); } } @@ -147,7 +147,7 @@ class Prometheus { } metric.inc(tags, delta); } catch (e) { - logger.error(`Prometheus: Counter metric ${name} failed with error ${e}. Value: ${delta}`); + logger.errorw(`Prometheus: Counter metric ${name} failed with error ${e}. Value: ${delta}`); } } @@ -162,7 +162,7 @@ class Prometheus { } metric.set(tags, value); } catch (e) { - logger.error(`Prometheus: Gauge metric ${name} failed with error ${e}. Value: ${value}`); + logger.errorw(`Prometheus: Gauge metric ${name} failed with error ${e}. Value: ${value}`); } } @@ -971,12 +971,12 @@ class Prometheus { metric.buckets, ); } else { - logger.error( + logger.errorw( `Prometheus: Metric creation failed. Name: ${metric.name}. Invalid type: ${metric.type}`, ); } } catch (e) { - logger.error(`Prometheus: Metric creation failed. Name: ${metric.name}. Error ${e}`); + logger.errorw(`Prometheus: Metric creation failed. Name: ${metric.name}. Error ${e}`); } }); } diff --git a/src/util/stats.js b/src/util/stats.js index e57ab85731..e7b21748d3 100644 --- a/src/util/stats.js +++ b/src/util/stats.js @@ -1,6 +1,7 @@ +import logger from '@rudderstack/integrations-lib/build/structured-logger'; + const statsd = require('./statsd'); const prometheus = require('./prometheus'); -const logger = require('../logger'); const enableStats = process.env.ENABLE_STATS !== 'false'; const statsClientType = process.env.STATS_CLIENT || 'statsd'; diff --git a/src/util/trackingPlan.js b/src/util/trackingPlan.js index a77265a5b8..f627daa9d8 100644 --- a/src/util/trackingPlan.js +++ b/src/util/trackingPlan.js @@ -1,6 +1,6 @@ const NodeCache = require('node-cache'); const { fetchWithProxy } = require('./fetch'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const { responseStatusHandler } = require('./utils'); const stats = require('./stats'); @@ -34,7 +34,7 @@ async function getTrackingPlan(tpId, version, workspaceId) { tpCache.set(`${tpId}::${version}`, myJson); return myJson; } catch (error) { - logger.error(`Failed during trackingPlan fetch : ${error}`); + logger.errorw(`Failed during trackingPlan fetch : ${error}`); stats.increment('get_tracking_plan_error'); throw error; } @@ -71,7 +71,7 @@ async function getEventSchema(tpId, tpVersion, eventType, eventName, workspaceId } return eventSchema; } catch (error) { - logger.info(`Failed during eventSchema fetch : ${JSON.stringify(error)}`); + logger.infow(`Failed during eventSchema fetch : ${JSON.stringify(error)}`); stats.increment('get_eventSchema_error'); throw error; } diff --git a/src/util/utils.js b/src/util/utils.js index 0ba6008368..3fbc8ca300 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -5,7 +5,7 @@ const { Resolver } = require('dns').promises; const fetch = require('node-fetch'); const util = require('util'); -const logger = require('../logger'); +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); const stats = require('./stats'); const resolver = new Resolver(); @@ -169,7 +169,7 @@ function processInfo() { } function logProcessInfo() { - logger.error(`Process info: `, util.inspect(processInfo(), false, null, true)); + logger.errorw(`Process info: `, util.inspect(processInfo(), false, null, true)); } // stringLiterals expected to be an array of strings. A line in trace should contain diff --git a/src/v0/destinations/algolia/util.js b/src/v0/destinations/algolia/util.js index eddb4dc16d..1940aebe71 100644 --- a/src/v0/destinations/algolia/util.js +++ b/src/v0/destinations/algolia/util.js @@ -32,18 +32,18 @@ const genericpayloadValidator = (payload) => { } if (payload.filters && !Array.isArray(payload.filters)) { updatedPayload.filters = null; - logger.error('filters should be an array of strings.'); + logger.errorw('filters should be an array of strings.'); } if (payload.queryID) { const re = /[\dA-Fa-f]{6}/; if (payload.queryID.length !== 32 || !re.test(String(payload.queryID))) { updatedPayload.queryID = null; - logger.error('queryId must be 32 characters hexadecimal string.'); + logger.errorw('queryId must be 32 characters hexadecimal string.'); } } if (payload.objectIDs && !Array.isArray(payload.objectIDs)) { updatedPayload.objectIDs = null; - logger.error('objectIds must be an array of strings'); + logger.errorw('objectIds must be an array of strings'); } if (payload.objectIDs && payload.objectIDs.length > 20) { updatedPayload.objectIDs.splice(20); @@ -52,7 +52,7 @@ const genericpayloadValidator = (payload) => { const diff = Date.now() - payload.timestamp; if (diff > 345600000) { updatedPayload.timestamp = null; - logger.error('timestamp must be max 4 days old.'); + logger.errorw('timestamp must be max 4 days old.'); } } if (payload.eventType !== 'click' && payload.positions) { @@ -74,7 +74,7 @@ const createObjectArray = (objects, eventType) => { objectList.push(object.objectId); positionList.push(object.position); } else { - logger.info( + logger.infow( `object at index ${index} dropped. position is required if eventType is click`, ); } @@ -82,7 +82,7 @@ const createObjectArray = (objects, eventType) => { objectList.push(object.objectId); } } else { - logger.error(`object at index ${index} dropped. objectId is required.`); + logger.errorw(`object at index ${index} dropped. objectId is required.`); } }); } @@ -94,7 +94,7 @@ const clickPayloadValidator = (payload) => { if (payload.positions) { if (!Array.isArray(payload.positions)) { updatedPayload.positions = null; - logger.error('positions should be an array of integers.'); + logger.errorw('positions should be an array of integers.'); } updatedPayload.positions.forEach((num, index) => { if (!Number.isNaN(Number(num)) && Number.isInteger(Number(num))) { diff --git a/src/v0/destinations/am/transform.js b/src/v0/destinations/am/transform.js index d78a5f727f..68a9eae513 100644 --- a/src/v0/destinations/am/transform.js +++ b/src/v0/destinations/am/transform.js @@ -427,7 +427,7 @@ const nonAliasResponsebuilder = ( } if (!payload.user_id && !payload.device_id) { - logger.debug('Either of user ID or device ID fields must be specified'); + logger.debugw('Either of user ID or device ID fields must be specified'); throw new InstrumentationError('Either of user ID or device ID fields must be specified'); } @@ -581,7 +581,7 @@ const getGroupInfo = (destination, groupInfo, groupTraits) => { updatedGroupInfo.group_properties = groupTraits; return updatedGroupInfo; } - logger.debug('Group call parameters are not valid'); + logger.debugw('Group call parameters are not valid'); throw new InstrumentationError('Group call parameters are not valid'); } return groupInfo; @@ -698,7 +698,7 @@ const processSingleMessage = (message, destination) => { } break; default: - logger.debug('could not determine type'); + logger.debugw('could not determine type'); throw new InstrumentationError('message type not supported'); } return responseBuilderSimple( diff --git a/src/v0/destinations/am/utils.js b/src/v0/destinations/am/utils.js index 71fe0ab459..22b2784ef3 100644 --- a/src/v0/destinations/am/utils.js +++ b/src/v0/destinations/am/utils.js @@ -76,7 +76,7 @@ const getEventId = (payload, sourceKey) => { if (isDefinedAndNotNull(eventId)) { if (typeof eventId === 'string') { - logger.info(`event_id should be integer only`); + logger.infow(`event_id should be integer only`); } else return eventId; } return undefined; diff --git a/src/v0/destinations/braze/transform.js b/src/v0/destinations/braze/transform.js index 6549f5658f..87465e2131 100644 --- a/src/v0/destinations/braze/transform.js +++ b/src/v0/destinations/braze/transform.js @@ -118,7 +118,7 @@ function populateCustomAttributesWithOperation( }); } } catch (exp) { - logger.info('Failure occurred during custom attributes operations', exp); + logger.infow('Failure occurred during custom attributes operations', exp); } } @@ -538,7 +538,7 @@ const processRouterDest = async (inputs, reqMetadata) => { try { lookedUpUsers = await BrazeDedupUtility.doLookup(inputs); } catch (error) { - logger.error('Error while fetching user store', error); + logger.errorw('Error while fetching user store', error); } BrazeDedupUtility.updateUserStore(userStore, lookedUpUsers, destination.ID); diff --git a/src/v0/destinations/campaign_manager/transform.js b/src/v0/destinations/campaign_manager/transform.js index b2bba5139a..d0d0eb7ec1 100644 --- a/src/v0/destinations/campaign_manager/transform.js +++ b/src/v0/destinations/campaign_manager/transform.js @@ -1,6 +1,6 @@ +const logger = require('@rudderstack/integrations-lib/build/structured-logger'); + const { InstrumentationError } = require('@rudderstack/integrations-lib'); -import logger from "@rudderstack/integrations-lib/build/structured-logger"; -import { MiscService } from '../../../services/misc'; const lodash = require('lodash'); const { EventType } = require('../../../constants'); const { diff --git a/src/v0/destinations/canny/util.js b/src/v0/destinations/canny/util.js index f514a01e5c..3b3f0bf5b5 100644 --- a/src/v0/destinations/canny/util.js +++ b/src/v0/destinations/canny/util.js @@ -48,7 +48,7 @@ const retrieveUserId = async (apiKey, message) => { endpointPath: `/v1/users/retrieve`, }, ); - logger.debug(response); + logger.debugw(response); // If the request fails, throwing error. if (response.success === false) { throw new NetworkError( diff --git a/src/v0/destinations/customerio/transform.js b/src/v0/destinations/customerio/transform.js index be4486717c..f092420cfa 100644 --- a/src/v0/destinations/customerio/transform.js +++ b/src/v0/destinations/customerio/transform.js @@ -112,7 +112,7 @@ function processSingleMessage(message, destination) { evType = 'group'; break; default: - logger.error(`could not determine type ${messageType}`); + logger.errorw(`could not determine type ${messageType}`); throw new InstrumentationError(`could not determine type ${messageType}`); } evName = evName ? String(evName) : evName; diff --git a/src/v0/destinations/delighted/transform.js b/src/v0/destinations/delighted/transform.js index cf80dc878d..372bdcff58 100644 --- a/src/v0/destinations/delighted/transform.js +++ b/src/v0/destinations/delighted/transform.js @@ -42,11 +42,11 @@ const identifyResponseBuilder = (message, { Config }) => { if (userIdType === 'email' && payload.phone_number) { if (!isValidPhone(payload.phone_number)) { payload.phone_number = null; - logger.error('Phone number format must be E.164.'); + logger.errorw('Phone number format must be E.164.'); } } else if (userIdType === 'phone_number' && payload.email && !isValidEmail(payload.email)) { payload.email = null; - logger.error('Email format is not correct.'); + logger.errorw('Email format is not correct.'); } payload.send = false; diff --git a/src/v0/destinations/drip/transform.js b/src/v0/destinations/drip/transform.js index 4ccba076d0..9cd60463aa 100644 --- a/src/v0/destinations/drip/transform.js +++ b/src/v0/destinations/drip/transform.js @@ -44,7 +44,7 @@ const identifyResponseBuilder = async (message, { Config }) => { let email = getFieldValueFromMessage(message, 'email'); if (!isValidEmail(email)) { email = null; - logger.error('Email format is incorrect'); + logger.errorw('Email format is incorrect'); } const userId = getFieldValueFromMessage(message, 'userId'); @@ -149,7 +149,7 @@ const trackResponseBuilder = async (message, { Config }) => { ]); if (!isValidEmail(email)) { email = null; - logger.error('Enter correct email format.'); + logger.errorw('Enter correct email format.'); } if (!id && !email) { throw new InstrumentationError('Drip Id or email is required.'); @@ -176,7 +176,7 @@ const trackResponseBuilder = async (message, { Config }) => { if (payload.occurred_at && !isValidTimestamp(payload.occurred_at)) { payload.occurred_at = null; - logger.error('Timestamp format must be ISO-8601.'); + logger.errorw('Timestamp format must be ISO-8601.'); } const productList = getValueFromMessage(message, 'properties.products'); if (productList) { @@ -204,7 +204,7 @@ const trackResponseBuilder = async (message, { Config }) => { payload.email = email; if (payload.occurred_at && !isValidTimestamp(payload.occurred_at)) { payload.occurred_at = null; - logger.error('Timestamp format must be ISO-8601.'); + logger.errorw('Timestamp format must be ISO-8601.'); } if (!payload.properties) { diff --git a/src/v0/destinations/drip/util.js b/src/v0/destinations/drip/util.js index a502cf0d20..6869dd971c 100644 --- a/src/v0/destinations/drip/util.js +++ b/src/v0/destinations/drip/util.js @@ -93,7 +93,7 @@ const createList = (productList) => { if (itemPayload.name && isDefinedAndNotNull(itemPayload.price)) { itemList.push(itemPayload); } else { - logger.error(`Item at index ${index} dropped. Name and price is required`); + logger.errorw(`Item at index ${index} dropped. Name and price is required`); } }); } diff --git a/src/v0/destinations/fb/transform.js b/src/v0/destinations/fb/transform.js index e6f8e986cf..b7ceb96c44 100644 --- a/src/v0/destinations/fb/transform.js +++ b/src/v0/destinations/fb/transform.js @@ -354,7 +354,7 @@ function processSingleMessage(message, destination) { updatedEvent = processEventTypeGeneric(message, baseEvent, fbEventName); break; default: - logger.error('could not determine type'); + logger.errorw('could not determine type'); throw new InstrumentationError(`Message type ${message.type} not supported`); } diff --git a/src/v0/destinations/freshmarketer/utils.js b/src/v0/destinations/freshmarketer/utils.js index 5e3ba6e67e..61eed6f6d9 100644 --- a/src/v0/destinations/freshmarketer/utils.js +++ b/src/v0/destinations/freshmarketer/utils.js @@ -150,7 +150,7 @@ const createOrUpdateListDetails = async (listName, Config) => { if (listResponse.status !== 200) { const errMessage = listResponse.response.errors?.message || ''; const errorStatus = listResponse.response.errors?.code || '500'; - logger.error(`failed to fetch list ${errMessage}`, errorStatus); + logger.errorw(`failed to fetch list ${errMessage}`, errorStatus); } const listsDetails = listResponse.response?.lists; @@ -170,7 +170,7 @@ const createOrUpdateListDetails = async (listName, Config) => { if (listResponse.status !== 200) { const errMessage = listResponse.response.errors?.message || ''; const errorStatus = listResponse.response.errors?.code || '500'; - logger.error(`failed to create list ${errMessage}`, errorStatus); + logger.errorw(`failed to create list ${errMessage}`, errorStatus); } const listId = listResponse.response?.list?.id; return listId; diff --git a/src/v0/destinations/gainsight/util.js b/src/v0/destinations/gainsight/util.js index 39e666c1a5..0b3942ae77 100644 --- a/src/v0/destinations/gainsight/util.js +++ b/src/v0/destinations/gainsight/util.js @@ -140,7 +140,7 @@ const renameCustomFieldsFromMap = (payload, fieldsMap, exlusionKeys) => { } else if (fieldMapKeys.includes(key)) { mappedPayload[fieldsMap[key]] = payload[key]; } else { - logger.info(`dropping key ${key}`); + logger.infow(`dropping key ${key}`); } }); return mappedPayload; diff --git a/src/v0/destinations/google_adwords_remarketing_lists/transform.js b/src/v0/destinations/google_adwords_remarketing_lists/transform.js index 9526973fb8..7a367fd086 100644 --- a/src/v0/destinations/google_adwords_remarketing_lists/transform.js +++ b/src/v0/destinations/google_adwords_remarketing_lists/transform.js @@ -111,7 +111,7 @@ const populateIdentifiers = (attributeArray, { Config }) => { if (element[attribute]) { userIdentifier.push({ [attribute]: element[attribute] }); } else { - logger.info(` ${attribute} is not present in index:`, index); + logger.infow(` ${attribute} is not present in index:`, index); } } else { attribute.forEach((attributeElement, index2) => { @@ -124,7 +124,7 @@ const populateIdentifiers = (attributeArray, { Config }) => { [`${attributeMapping[attributeElement]}`]: element[`${attributeElement}`], }); } else { - logger.info(` ${attribute[index2]} is not present in index:`, index); + logger.infow(` ${attribute[index2]} is not present in index:`, index); } }); } @@ -153,7 +153,7 @@ const createPayload = (message, destination) => { if (properties.includes(key)) { const userIdentifiersList = populateIdentifiers(listData[key], destination); if (userIdentifiersList.length === 0) { - logger.info( + logger.infow( `Google_adwords_remarketing_list]:: No attributes are present in the '${key}' property.`, ); return; @@ -190,7 +190,7 @@ const createPayload = (message, destination) => { default: } } else { - logger.info(`listData "${key}" is not valid. Supported types are "add" and "remove"`); + logger.infow(`listData "${key}" is not valid. Supported types are "add" and "remove"`); } }); diff --git a/src/v0/destinations/mailchimp/utils.js b/src/v0/destinations/mailchimp/utils.js index e1e2e9883b..111e6ed3de 100644 --- a/src/v0/destinations/mailchimp/utils.js +++ b/src/v0/destinations/mailchimp/utils.js @@ -170,7 +170,7 @@ const checkIfMailExists = async (apiKey, datacenterId, audienceId, email) => { userStatus.subscriptionStatus = response.data.status; } } catch (error) { - logger.info(`[Mailchimp] :: Email does not exists, Error: ${error.message}`); + logger.infow(`[Mailchimp] :: Email does not exists, Error: ${error.message}`); } return userStatus; }; diff --git a/src/v0/destinations/marketo/transform.js b/src/v0/destinations/marketo/transform.js index 5000ef506b..ea867c7e4b 100644 --- a/src/v0/destinations/marketo/transform.js +++ b/src/v0/destinations/marketo/transform.js @@ -469,9 +469,9 @@ const processRouterDest = async (inputs, reqMetadata) => { throw new UnauthorizedError('Authorization failed'); } } catch (error) { - logger.error('Router Transformation problem:'); + logger.errorw('Router Transformation problem:'); const errObj = generateErrorObject(error); - logger.error(errObj); + logger.errorw(errObj); const respEvents = getErrorRespEvents( inputs.map((input) => input.metadata), errObj.status, diff --git a/src/v0/destinations/marketo/util.js b/src/v0/destinations/marketo/util.js index 54ff70708a..967c7a53b1 100644 --- a/src/v0/destinations/marketo/util.js +++ b/src/v0/destinations/marketo/util.js @@ -219,7 +219,7 @@ const marketoResponseHandler = ( authKey && response.errors.some((errorObj) => errorObj.code === '601' || errorObj.code === '602') ) { - logger.info( + logger.infow( `${destination} Cache token evicting due to invalid/expired access_token for destinationId (${authKey})`, ); authCache.del(authKey); diff --git a/src/v0/destinations/marketo_bulk_upload/util.js b/src/v0/destinations/marketo_bulk_upload/util.js index fac04af431..8e515c6137 100644 --- a/src/v0/destinations/marketo_bulk_upload/util.js +++ b/src/v0/destinations/marketo_bulk_upload/util.js @@ -230,7 +230,7 @@ const handleFetchJobStatusResponse = (resp, type) => { const marketoReposnseStatus = resp.status; if (!isHttpStatusSuccess(marketoReposnseStatus)) { - logger.info('[Network Error]:Failed during fetching job status', { marketoResponse, type }); + logger.infow('[Network Error]:Failed during fetching job status', { marketoResponse, type }); throw new NetworkError( `Unable to fetch job status: due to error ${JSON.stringify(marketoResponse)}`, hydrateStatusForServer(marketoReposnseStatus, 'During fetching job status'), @@ -238,7 +238,7 @@ const handleFetchJobStatusResponse = (resp, type) => { } if (marketoResponse?.success === false) { - logger.info('[Application Error]Failed during fetching job status', { marketoResponse, type }); + logger.infow('[Application Error]Failed during fetching job status', { marketoResponse, type }); throw new RetryableError( `Failure during fetching job status due to error : ${marketoResponse}`, 500, diff --git a/src/v0/destinations/ometria/util.js b/src/v0/destinations/ometria/util.js index 304c4fe5b2..eb9c3b5e42 100644 --- a/src/v0/destinations/ometria/util.js +++ b/src/v0/destinations/ometria/util.js @@ -29,7 +29,7 @@ const createVariantList = (variants) => { if (variantPayload.id && variantPayload.type && variantPayload.label) { variantList.push(variantPayload); } else { - logger.error(`variant at index ${index} dropped. Id, type and label are required.`); + logger.errorw(`variant at index ${index} dropped. Id, type and label are required.`); } }); } @@ -48,7 +48,7 @@ const createLineItems = (items) => { ) { const variantList = item.variant_options; if (!variantList || !Array.isArray(variantList)) { - logger.error('variant options must be an array of objects.'); + logger.errorw('variant options must be an array of objects.'); } else { const variantOptions = createVariantList(variantList); if (variantOptions && variantOptions.length > 0) { @@ -72,7 +72,7 @@ const createLineItems = (items) => { } itemList.push(removeUndefinedAndNullValues(itemPayload)); } else { - logger.error( + logger.errorw( `item at index ${index} dropped. Product id , quantity and either unit_price or subtotal are required.`, ); } @@ -83,7 +83,7 @@ const createLineItems = (items) => { const addressMappper = (address) => { if (!isObject(address)) { - logger.error('billing address or shipping address should be an object.'); + logger.errorw('billing address or shipping address should be an object.'); return null; } const res = { @@ -100,25 +100,25 @@ const contactPayloadValidator = (payload) => { const FORCE_OPT_IN_KEY = '@force_optin'; if (payload[FORCE_OPT_IN_KEY] && typeof payload[FORCE_OPT_IN_KEY] !== 'boolean') { updatedPayload[FORCE_OPT_IN_KEY] = null; - logger.error('forceOptin must contain only boolean value.'); + logger.errorw('forceOptin must contain only boolean value.'); } if (payload.phone_number && !isValidPhone(payload.phone_number)) { updatedPayload.phone_number = null; - logger.error('phone number format must be E.164.'); + logger.errorw('phone number format must be E.164.'); } const TIMESTAMP_FORMAT_ERR_MSG = 'timestamp format must be ISO 8601'; if (payload.timestamp_acquired && !isValidTimestamp(payload.timestamp_acquired)) { updatedPayload.timestamp_acquired = null; - logger.error(TIMESTAMP_FORMAT_ERR_MSG); + logger.errorw(TIMESTAMP_FORMAT_ERR_MSG); } if (payload.timestamp_subscribed && !isValidTimestamp(payload.timestamp_subscribed)) { updatedPayload.timestamp_subscribed = null; - logger.error(TIMESTAMP_FORMAT_ERR_MSG); + logger.errorw(TIMESTAMP_FORMAT_ERR_MSG); } if (payload.timestamp_unsubscribed && !isValidTimestamp(payload.timestamp_unsubscribed)) { updatedPayload.timestamp_unsubscribed = null; - logger.error(TIMESTAMP_FORMAT_ERR_MSG); + logger.errorw(TIMESTAMP_FORMAT_ERR_MSG); } return updatedPayload; }; diff --git a/src/v0/destinations/pardot/transform.js b/src/v0/destinations/pardot/transform.js index b32b8967bd..532aa9ba1a 100644 --- a/src/v0/destinations/pardot/transform.js +++ b/src/v0/destinations/pardot/transform.js @@ -79,7 +79,7 @@ const getUrl = (urlParams) => { const { externalId, category, email, nonProperExtId } = urlParams; let properUrl = `${category.endPointUpsert}/email/${email}`; if (nonProperExtId) { - logger.debug(`${DESTINATION}: externalId doesn't exist/invalid datastructure`); + logger.debugw(`${DESTINATION}: externalId doesn't exist/invalid datastructure`); return properUrl; } // when there is a proper externalId object defined @@ -91,7 +91,7 @@ const getUrl = (urlParams) => { properUrl = `${category.endPointUpsert}/fid/${externalId.id}`; break; default: - logger.debug(`${DESTINATION}: externalId type is different from the ones supported`); + logger.debugw(`${DESTINATION}: externalId type is different from the ones supported`); break; } return properUrl; diff --git a/src/v0/destinations/sendgrid/util.js b/src/v0/destinations/sendgrid/util.js index 1df34bfe69..b6c257ee0c 100644 --- a/src/v0/destinations/sendgrid/util.js +++ b/src/v0/destinations/sendgrid/util.js @@ -97,7 +97,7 @@ const payloadValidator = (payload) => { } }); } else { - logger.error(`item at index ${index} dropped. to field is mandatory`); + logger.errorw(`item at index ${index} dropped. to field is mandatory`); } updatedPayload.personalizations[index].to = personalizationsArr; }); @@ -106,11 +106,11 @@ const payloadValidator = (payload) => { payload.attachments.forEach((attachment, index) => { if (!attachment.content || !attachment.filename) { updatedPayload.attachments[index] = null; - logger.error('content and filename are required for attachments'); + logger.errorw('content and filename are required for attachments'); } if (payload.attachments.content && !isValidBase64(payload.attachments.content)) { updatedPayload.attachments[index] = null; - logger.error('content should be base64 encoded'); + logger.errorw('content should be base64 encoded'); } }); } @@ -132,11 +132,11 @@ const payloadValidator = (payload) => { delete updatedPayload.reply_to; } if (payload.reply_to && !payload.reply_to.email) { - logger.error('reply_to object requires email field'); + logger.errorw('reply_to object requires email field'); delete updatedPayload.reply_to; } if (payload.asm && payload.asm.groups_to_display && !payload.asm.group_id) { - logger.error('group Id parameter is required in asm'); + logger.errorw('group Id parameter is required in asm'); delete updatedPayload.asm; } if (isEmptyObject(payload.asm)) { @@ -170,7 +170,7 @@ const createContent = (Config) => { if (content.type && content.value) { contentList.push(content); } else if (index < len) { - logger.error(`item at index ${index} dropped. type and value are required fields`); + logger.errorw(`item at index ${index} dropped. type and value are required fields`); } }); } @@ -185,7 +185,7 @@ const createAttachments = (Config) => { if (attachment.content && attachment.filename) { attachmentList.push(removeUndefinedAndNullAndEmptyValues(attachment)); } else if (index < len) { - logger.error(`item at index ${index} dropped. content and type are required fields`); + logger.errorw(`item at index ${index} dropped. content and type are required fields`); } }); } diff --git a/src/v0/destinations/slack/transform.js b/src/v0/destinations/slack/transform.js index 41282c6887..de62358284 100644 --- a/src/v0/destinations/slack/transform.js +++ b/src/v0/destinations/slack/transform.js @@ -49,7 +49,7 @@ const buildResponse = ( payload, }; response.statusCode = 200; - logger.debug(response); + logger.debugw(response); return response; }; @@ -57,7 +57,7 @@ const processIdentify = (message, destination) => { const identifyTemplateConfig = destination.Config.identifyTemplate; const traitsList = getWhiteListedTraits(destination); const defaultIdentifyTemplate = 'Identified {{name}}'; - logger.debug('defaulTraitsList:: ', traitsList); + logger.debugw('defaulTraitsList:: ', traitsList); const uName = getName(message); const template = Handlebars.compile( @@ -72,7 +72,7 @@ const processIdentify = (message, destination) => { defaultIdentifyTemplate || {}, ), ); - logger.debug( + logger.debugw( 'identifyTemplateConfig: ', (identifyTemplateConfig ? identifyTemplateConfig.trim()?.length === 0 @@ -112,8 +112,8 @@ const getChannelForEventName = (eventChannelSettings, eventName) => { if (configEventName && isDefinedAndNotNull(channelWebhook)) { if (channelConfig.eventRegex) { - logger.debug('regex: ', `${configEventName} trying to match with ${eventName}`); - logger.debug( + logger.debugw('regex: ', `${configEventName} trying to match with ${eventName}`); + logger.debugw( 'match:: ', configEventName, eventName, @@ -137,8 +137,8 @@ const getChannelNameForEvent = (eventChannelSettings, eventName) => { channelConfig?.eventChannel?.trim()?.length > 0 ? channelConfig.eventChannel : null; if (configEventName && configEventChannel) { if (channelConfig.eventRegex) { - logger.debug('regex: ', `${configEventName} trying to match with ${eventName}`); - logger.debug( + logger.debugw('regex: ', `${configEventName} trying to match with ${eventName}`); + logger.debugw( 'match:: ', configEventName, eventName, @@ -177,7 +177,7 @@ const buildtemplateList = (templateListForThisEvent, eventTemplateSettings, even }; const processTrack = (message, destination) => { - // logger.debug(JSON.stringify(destination)); + // logger.debugw(JSON.stringify(destination)); const { Config } = destination; const { eventChannelSettings, eventTemplateSettings, incomingWebhooksType, denyListOfEvents } = Config; @@ -217,7 +217,7 @@ const processTrack = (message, destination) => { buildtemplateList(templateListForThisEvent, eventTemplateSettings, eventName); const templateListArray = Array.from(templateListForThisEvent); - logger.debug( + logger.debugw( 'templateListForThisEvent: ', templateListArray, templateListArray.length > 0 ? templateListArray[0] : undefined, @@ -244,7 +244,7 @@ const processTrack = (message, destination) => { traitsList: identityTraits, }; - logger.debug('templateInputTrack: ', templateInput); + logger.debugw('templateInputTrack: ', templateInput); let resultText; try { @@ -267,8 +267,8 @@ const processTrack = (message, destination) => { }; const process = (event) => { - logger.debug('=====start====='); - logger.debug(JSON.stringify(event)); + logger.debugw('=====start====='); + logger.debugw(JSON.stringify(event)); const respList = []; let response; const { message, destination } = event; @@ -276,7 +276,7 @@ const process = (event) => { throw new InstrumentationError('Event type is required'); } const messageType = message.type.toLowerCase(); - logger.debug('messageType: ', messageType); + logger.debugw('messageType: ', messageType); switch (messageType) { case EventType.IDENTIFY: @@ -290,11 +290,11 @@ const process = (event) => { respList.push(response); break; default: - logger.debug('Message type not supported'); + logger.debugw('Message type not supported'); throw new InstrumentationError(`Event type ${messageType} is not supported`); } - logger.debug(JSON.stringify(respList)); - logger.debug('=====end======'); + logger.debugw(JSON.stringify(respList)); + logger.debugw('=====end======'); return respList; }; diff --git a/src/v0/destinations/snapchat_conversion/util.js b/src/v0/destinations/snapchat_conversion/util.js index ee0329995c..fc0cb97cf7 100644 --- a/src/v0/destinations/snapchat_conversion/util.js +++ b/src/v0/destinations/snapchat_conversion/util.js @@ -80,7 +80,7 @@ function getItemIds(message) { if (pId) { itemIds.push(pId); } else { - logger.debug(`product_id not present for product at index ${index}`); + logger.debugw(`product_id not present for product at index ${index}`); } }); } else { diff --git a/src/v0/destinations/zendesk/transform.js b/src/v0/destinations/zendesk/transform.js index bf2bc01ed2..54566c71bb 100644 --- a/src/v0/destinations/zendesk/transform.js +++ b/src/v0/destinations/zendesk/transform.js @@ -120,9 +120,9 @@ const payloadBuilderforUpdatingEmail = async (userId, headers, userEmail, baseEn } } } - logger.debug(`${NAME}:: Failed in fetching Identity details`); + logger.debugw(`${NAME}:: Failed in fetching Identity details`); } catch (error) { - logger.debug(`${NAME}:: Error :`, error.response ? error.response.data : error); + logger.debugw(`${NAME}:: Error :`, error.response ? error.response.data : error); } return {}; }; @@ -149,11 +149,11 @@ async function createUserFields(url, config, newFields, fieldJson) { feature: 'transformation', }); if (response.status !== 201) { - logger.debug(`${NAME}:: Failed to create User Field : `, field); + logger.debugw(`${NAME}:: Failed to create User Field : `, field); } } catch (error) { if (error.response && error.response.status !== 422) { - logger.debug(`${NAME}:: Cannot create User field `, field, error); + logger.debugw(`${NAME}:: Cannot create User field `, field, error); } } }), @@ -194,7 +194,7 @@ async function checkAndCreateUserFields( } } } catch (error) { - logger.debug(`${NAME}:: Error :`, error.response ? error.response.data : error); + logger.debugw(`${NAME}:: Error :`, error.response ? error.response.data : error); } } @@ -243,7 +243,7 @@ function getIdentifyPayload(message, category, destinationConfig, type) { const getUserIdByExternalId = async (message, headers, baseEndpoint) => { const externalId = getFieldValueFromMessage(message, 'userIdOnly'); if (!externalId) { - logger.debug(`${NAME}:: externalId is required for getting zenuserId`); + logger.debugw(`${NAME}:: externalId is required for getting zenuserId`); return undefined; } const url = `${baseEndpoint}users/search.json?query=${externalId}`; @@ -259,9 +259,9 @@ const getUserIdByExternalId = async (message, headers, baseEndpoint) => { const zendeskUserId = get(resp, 'response.data.users.0.id'); return zendeskUserId; } - logger.debug(`${NAME}:: Failed in fetching User details`); + logger.debugw(`${NAME}:: Failed in fetching User details`); } catch (error) { - logger.debug(`${NAME}:: Cannot get userId for externalId : ${externalId}`, error.response); + logger.debugw(`${NAME}:: Cannot get userId for externalId : ${externalId}`, error.response); } return undefined; }; @@ -273,7 +273,7 @@ async function getUserId(message, headers, baseEndpoint, type) { : getFieldValueFromMessage(message, 'traits'); const userEmail = traits?.email || traits?.primaryEmail; if (!userEmail) { - logger.debug(`${NAME}:: Email ID is required for getting zenuserId`); + logger.debugw(`${NAME}:: Email ID is required for getting zenuserId`); return undefined; } const url = `${baseEndpoint}users/search.json?query=${userEmail}`; @@ -285,14 +285,14 @@ async function getUserId(message, headers, baseEndpoint, type) { feature: 'transformation', }); if (!resp || !resp.data || resp.data.count === 0) { - logger.debug(`${NAME}:: User not found`); + logger.debugw(`${NAME}:: User not found`); return undefined; } const zendeskUserId = resp?.data?.users?.[0]?.id; return zendeskUserId; } catch (error) { - // logger.debug( + // logger.debugw( // `Cannot get userId for externalId : ${externalId}`, // error.response // ); @@ -312,8 +312,8 @@ async function isUserAlreadyAssociated(userId, orgId, headers, baseEndpoint) { return true; } } catch (error) { - logger.debug(`${NAME}:: Error :`); - logger.debug(error?.response?.data || error); + logger.debugw(`${NAME}:: Error :`); + logger.debugw(error?.response?.data || error); } return false; } @@ -342,7 +342,7 @@ async function createUser(message, headers, destinationConfig, baseEndpoint, typ }); if (!resp.data || !resp.data.user || !resp.data.user.id) { - logger.debug(`${NAME}:: Couldn't create User: ${name}`); + logger.debugw(`${NAME}:: Couldn't create User: ${name}`); throw new NetworkInstrumentationError('user not found'); } @@ -350,8 +350,8 @@ async function createUser(message, headers, destinationConfig, baseEndpoint, typ const userEmail = resp?.data?.user.email; return { zendeskUserId: userID, email: userEmail }; } catch (error) { - logger.debug(error); - logger.debug(`Couldn't find user: ${name}`); + logger.debugw(error); + logger.debugw(`Couldn't find user: ${name}`); throw new NetworkInstrumentationError(`Couldn't find user: ${name}`); } } @@ -423,14 +423,14 @@ async function createOrganization(message, category, headers, destinationConfig, }); if (!resp.data || !resp.data.organization) { - logger.debug(`${NAME}:: Couldn't create Organization: ${message.traits.name}`); + logger.debugw(`${NAME}:: Couldn't create Organization: ${message.traits.name}`); return undefined; } const orgId = resp?.data?.organization?.id; return orgId; } catch (error) { - logger.debug(`${NAME}:: Couldn't create Organization: ${message.traits.name}`); + logger.debugw(`${NAME}:: Couldn't create Organization: ${message.traits.name}`); return undefined; } } @@ -508,7 +508,7 @@ async function processIdentify(message, destinationConfig, headers, baseEndpoint returnList.push(deleteResponse); } } catch (error) { - logger.debug(`${NAME}:: ${error}`); + logger.debugw(`${NAME}:: ${error}`); } } } diff --git a/src/v0/sources/shopify/transform.js b/src/v0/sources/shopify/transform.js index 013580d7a3..17d31c10b4 100644 --- a/src/v0/sources/shopify/transform.js +++ b/src/v0/sources/shopify/transform.js @@ -240,7 +240,7 @@ const processIdentifierEvent = async (event, metricMetadata) => { }); await RedisDB.setVal(`${event.cartToken}`, value); } catch (e) { - logger.debug(`{{SHOPIFY::}} cartToken map set call Failed due redis error ${e}`); + logger.debugw(`{{SHOPIFY::}} cartToken map set call Failed due redis error ${e}`); stats.increment('shopify_redis_failures', { type: 'set', ...metricMetadata, diff --git a/src/v0/sources/shopify/util.js b/src/v0/sources/shopify/util.js index 6f31ade4a7..5a0cc0e9ad 100644 --- a/src/v0/sources/shopify/util.js +++ b/src/v0/sources/shopify/util.js @@ -42,7 +42,7 @@ const getDataFromRedis = async (key, metricMetadata) => { } return redisData; } catch (e) { - logger.debug(`{{SHOPIFY::}} Get call Failed due redis error ${e}`); + logger.debugw(`{{SHOPIFY::}} Get call Failed due redis error ${e}`); stats.increment('shopify_redis_failures', { type: 'get', ...metricMetadata, @@ -58,7 +58,7 @@ const getDataFromRedis = async (key, metricMetadata) => { */ const getShopifyTopic = (event) => { const { query_parameters: qParams } = event; - logger.debug(`[Shopify] Input event: query_params: ${JSON.stringify(qParams)}`); + logger.debugw(`[Shopify] Input event: query_params: ${JSON.stringify(qParams)}`); if (!qParams) { throw new TransformationError('Query_parameters is missing'); } @@ -219,7 +219,7 @@ const updateCartItemsInRedis = async (cartToken, newCartItemsHash, metricMetadat }); await RedisDB.setVal(`${cartToken}`, value); } catch (e) { - logger.debug(`{{SHOPIFY::}} itemsHash set call Failed due redis error ${e}`); + logger.debugw(`{{SHOPIFY::}} itemsHash set call Failed due redis error ${e}`); stats.increment('shopify_redis_failures', { type: 'set', ...metricMetadata, diff --git a/src/v0/util/index.js b/src/v0/util/index.js index 0cc66b2d7a..3246d5b1aa 100644 --- a/src/v0/util/index.js +++ b/src/v0/util/index.js @@ -822,14 +822,14 @@ function formatValues(formattedVal, formattingType, typeFormat, integrationsObj) IsBoolean: () => { curFormattedVal = true; if (!(typeof formattedVal === 'boolean')) { - logger.debug('Boolean value missing, so dropping it'); + logger.debugw('Boolean value missing, so dropping it'); curFormattedVal = false; } }, IsArray: () => { curFormattedVal = formattedVal; if (!Array.isArray(formattedVal)) { - logger.debug('Array value missing, so dropping it'); + logger.debugw('Array value missing, so dropping it'); curFormattedVal = undefined; } }, @@ -1360,7 +1360,7 @@ function extractCustomFields(message, payload, keys, exclusionFields) { } }); } else { - logger.debug('unable to parse keys'); + logger.debugw('unable to parse keys'); } return payload; @@ -1500,7 +1500,7 @@ const getErrorStatusCode = (error, defaultStatusCode = HTTP_STATUS_CODES.INTERNA .find((stCode) => lodash.isNumber(stCode)); return errStCode || defaultStCode; } catch (err) { - logger.error('Failed in getErrorStatusCode', err); + logger.errorw('Failed in getErrorStatusCode', err); return defaultStatusCode; } }; diff --git a/src/warehouse/config/helpers.js b/src/warehouse/config/helpers.js index ef00d7ee73..717ffcbbe8 100644 --- a/src/warehouse/config/helpers.js +++ b/src/warehouse/config/helpers.js @@ -10,7 +10,7 @@ const isBlank = (value) => { try { return _.isEmpty(_.toString(value)); } catch (e) { - logger.error(`Error in isBlank: ${e.message}`); + logger.errorw(`Error in isBlank: ${e.message}`); return false; } };