Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next fix logger error order #4006

Merged
merged 2 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class CreateLog {
try {
rawData = JSON.stringify(command.raw);
} catch (error) {
Logger.error('Parsing raw data when creating a log failed', error, LOG_CONTEXT);
Logger.error(error, 'Parsing raw data when creating a log failed', LOG_CONTEXT);
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/inbound-mail/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class Mailin extends events.EventEmitter {
.then(postQueue.bind(null, connection))
.then(unlinkFile.bind(null, connection))
.catch(function (error) {
logger.error(connection.id + ' Unable to finish processing message!!', error);
logger.error(error, connection.id + ' Unable to finish processing message!!');
logger.error(error);
throw error;
});
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/src/app/shared/logs/create-log.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CreateLog {
try {
rawData = JSON.stringify(command.raw);
} catch (error) {
Logger.error('Parsing raw data when creating a log failed', error, LOG_CONTEXT);
Logger.error(error, 'Parsing raw data when creating a log failed', LOG_CONTEXT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MetricQueueService extends QueueService<Record<string, never>> {

return undefined;
})
.catch((error) => Logger.error('Metric Job Exists function errored', error, LOG_CONTEXT));
.catch((error) => Logger.error(error, 'Metric Job Exists function errored', LOG_CONTEXT));
}

private getWorkerOptions(): WorkerOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class WorkflowQueueService extends QueueService<IJobData> implements INov

.then(resolve)
.catch((error) => {
Logger.error(`Failed to run the job ${jobId} during worker processing`, error, LOG_CONTEXT);
Logger.error(error, `Failed to run the job ${jobId} during worker processing`, LOG_CONTEXT);

return reject(error);
})
Expand Down Expand Up @@ -113,7 +113,7 @@ export class WorkflowQueueService extends QueueService<IJobData> implements INov
})
);
} catch (error) {
Logger.error(`Failed to set job ${jobId} as completed`, error, LOG_CONTEXT);
Logger.error(error, `Failed to set job ${jobId} as completed`, LOG_CONTEXT);
}
}

Expand Down Expand Up @@ -155,7 +155,7 @@ export class WorkflowQueueService extends QueueService<IJobData> implements INov
await this.handleLastFailedJob.execute(handleLastFailedJobCommand);
}
} catch (anotherError) {
Logger.error(`Failed to set job ${jobId} as failed`, anotherError, LOG_CONTEXT);
Logger.error(anotherError, `Failed to set job ${jobId} as failed`, LOG_CONTEXT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class SendMessageChat extends SendMessageBase {
* Do nothing, one chat channel failed, perhaps another one succeeds
* The failed message has been created
*/
Logger.error(`Sending chat message to the chat channel ${channel.providerId} failed`, e, LOG_CONTEXT);
Logger.error(e, `Sending chat message to the chat channel ${channel.providerId} failed`, LOG_CONTEXT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export class WebhookFilterBackoffStrategy {
})
);
} catch (anotherError) {
Logger.error('Failed to create the execution details for backoff stategy', anotherError);
Logger.error(
anotherError,
'Failed to create the execution details for backoff strategy',
'WebhookFilterBackoffStrategy'
);
}

return Math.round(Math.random() * Math.pow(2, attemptsMade) * 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class SocketQueueConsumerService {
);
} catch (e) {
// eslint-disable-next-line no-console
Logger.error('Unexpected exception occurred while handling external services route ', e, this.LOG_CONTEXT);
Logger.error(e, 'Unexpected exception occurred while handling external services route ', this.LOG_CONTEXT);

throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ export class AnalyticsService {
});
} catch (error: any) {
Logger.error(
'There has been an error when tracking',
{
eventName: name,
usedId: userId,
message: error.message,
},
'There has been an error when tracking',
LOG_CONTEXT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export class CacheService implements ICacheService {
await pipeline.exec();
} catch (error) {
Logger.error(
`Failed to execute pipeline action ${action} for key ${key}`,
error,
`Failed to execute pipeline action ${action} for key ${key}`,
LOG_CONTEXT
);
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export function CachedEntity({
}
} catch (err) {
Logger.error(
`An error has occurred when extracting "key: ${cacheKey}" in "method: ${methodName}"`,
err,
`An error has occurred when extracting "key: ${cacheKey}" in "method: ${methodName}"`,
LOG_CONTEXT
);
}
Expand All @@ -50,8 +50,8 @@ export function CachedEntity({
} catch (err) {
// eslint-disable-next-line no-console
Logger.error(
`An error has occurred when inserting "key: ${cacheKey}" in "method: ${methodName}" with "value: ${response}"`,
err,
`An error has occurred when inserting key: ${cacheKey} in "method: ${methodName}`,
LOG_CONTEXT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function CachedQuery({ builder }: { builder: (...args) => string }) {
}
} catch (err) {
Logger.error(
`An error has occurred when extracting "key: ${cacheKey}" in "method: ${methodName}"`,
err,
`An error has occurred when extracting "key: ${cacheKey}" in "method: ${methodName}"`,
LOG_CONTEXT
);
}
Expand All @@ -44,8 +44,8 @@ export function CachedQuery({ builder }: { builder: (...args) => string }) {
await cacheService.setQuery(cacheKey, JSON.stringify(response));
} catch (err) {
Logger.error(
`An error has occurred when inserting "key: ${cacheKey}" in "method: ${methodName}" with "value: ${response}"`,
err,
`An error has occurred when inserting key: ${cacheKey} in method: ${methodName}`,
LOG_CONTEXT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export function Cached(storeKeyPrefix: CacheKeyPrefixEnum) {
}
} catch (err) {
Logger.error(
`An error has occurred when extracting "key: ${cacheKey}" in "method: ${methodName}"`,
err,
`An error has occurred when extracting "key: ${cacheKey}" in "method: ${methodName}"`,
LOG_CONTEXT
);
}
Expand All @@ -54,8 +54,8 @@ export function Cached(storeKeyPrefix: CacheKeyPrefixEnum) {
await this.cacheService.set(cacheKey, JSON.stringify(response));
} catch (err) {
Logger.error(
`An error has occurred when inserting "key: ${cacheKey}" in "method: ${methodName}" with "value: ${response}"`,
err,
`An error has occurred when inserting key: ${cacheKey} in "method: ${methodName}`,
LOG_CONTEXT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class InvalidateCacheService {
await this.cacheService.del(key);
} catch (err) {
Logger.error(
`An error has occurred when deleting "key: ${key}",`,
err,
`An error has occurred when deleting "key: ${key}",`,
LOG_CONTEXT
);
}
Expand All @@ -34,8 +34,8 @@ export class InvalidateCacheService {
await this.cacheService.delQuery(key);
} catch (err) {
Logger.error(
`An error has occurred when deleting "key: ${key}",`,
err,
`An error has occurred when deleting "key: ${key}",`,
LOG_CONTEXT
);
}
Expand Down Expand Up @@ -66,8 +66,8 @@ export class InvalidateCacheService {
Logger.verbose('Finished cache delete by pattern');
} catch (err) {
Logger.error(
`An error has occurred when deleting "key: ${cacheKey}",`,
err,
`An error has occurred when deleting "key: ${cacheKey}",`,
LOG_CONTEXT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export class DistributedLockService {
*/
this.distributedLock.on('error', (error) => {
Logger.error(
'There has been an error in the Distributed Lock service',
error,
'There has been an error in the Distributed Lock service',
LOG_CONTEXT
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class FeatureFlagsService {
);
} catch (error) {
Logger.error(
'Feature Flags service has failed when shut down',
error,
'Feature Flags service has failed when shut down',
LOG_CONTEXT
);
}
Expand Down Expand Up @@ -98,8 +98,8 @@ export class FeatureFlagsService {
);
} catch (error) {
Logger.error(
'Feature Flags service has failed when initialized',
error,
'Feature Flags service has failed when initialized',
LOG_CONTEXT
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ export class InMemoryProviderService {
});
} catch (e) {
Logger.error(
'Connecting to cluster executing intervals has failed',
e,
'Connecting to cluster executing intervals has failed',
LOG_CONTEXT
);
}
Expand Down Expand Up @@ -202,8 +202,8 @@ export class InMemoryProviderService {

inMemoryProviderClient.on('error', (error) => {
Logger.error(
'There has been an error in the InMemory Cluster provider client',
error,
'There has been an error in the InMemory Cluster provider client',
LOG_CONTEXT
);
});
Expand Down Expand Up @@ -252,8 +252,8 @@ export class InMemoryProviderService {

inMemoryProviderClient.on('error', (error) => {
Logger.error(
'There has been an error in the InMemory provider client',
error,
'There has been an error in the InMemory provider client',
LOG_CONTEXT
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class LaunchDarklyService implements IFeatureFlagsService {
);
} catch (error) {
Logger.error(
'Launch Darkly SDK has failed when initialized',
error,
'Launch Darkly SDK has failed when initialized',
LOG_CONTEXT
);
throw error;
Expand Down Expand Up @@ -98,8 +98,8 @@ export class LaunchDarklyService implements IFeatureFlagsService {
);
} catch (error) {
Logger.error(
'Launch Darkly SDK has failed when shut down',
error,
'Launch Darkly SDK has failed when shut down',
LOG_CONTEXT
);
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class ReadinessService {
return healths.every((health) => !!health === true);
} catch (error) {
Logger.error(
'Some health indicator throw an error when checking if queues are enabled',
error,
'Some health indicator throw an error when checking if queues are enabled',
LOG_CONTEXT
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class CreateNotificationJobs {
if (!notification) {
const message = 'Notification could not be created';
const error = new PlatformException(message);
Logger.error(message, error, LOG_CONTEXT);
Logger.error(error, message, LOG_CONTEXT);
throw error;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export class DigestFilterSteps {
return result;
} catch (error) {
Logger.error(
'Failure when parsing digest payload nested key',
error,
'Failure when parsing digest payload nested key',
LOG_CONTEXT
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TriggerEvent {
if (!template) {
const message = 'Notification template could not be found';
const error = new ApiException(message);
Logger.error(message, error, LOG_CONTEXT);
Logger.error(error, message, LOG_CONTEXT);
throw error;
}

Expand Down