-
Notifications
You must be signed in to change notification settings - Fork 14
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
#3889 - Increase Logging for SFTP and file handling #3897
#3889 - Increase Logging for SFTP and file handling #3897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Job @andrewsignori-aot . 2 minor comments and a question.
} catch (error) { | ||
this.logger.error(`Error uploading file ${remoteFilePath}.`, error); | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
sources/packages/backend/libs/integrations/src/services/ssh/sftp-integration-base.ts
Outdated
Show resolved
Hide resolved
...ckages/backend/libs/integrations/src/sfas-integration/sfas-integration.processing.service.ts
Show resolved
Hide resolved
error(message: unknown, error?: unknown, context?: string): void { | ||
const errorBuilder = new StringBuilder(); | ||
if (typeof message === "string") { | ||
errorBuilder.appendLine(message); | ||
} else { | ||
errorBuilder.appendLine(parseJSONError(message)); | ||
} | ||
if (error) { | ||
errorBuilder.appendLine(parseJSONError(error)); | ||
} | ||
super.error(errorBuilder.toString(), context); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asking for my understanding, how badly it looks in comparison when we use the super class methods OOTB?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see below the details.
Without the change using the below.
this.logger.error(`Error uploading file ${remoteFilePath}.`);
this.logger.error(error);
Using the below.
this.logger.error(`Error uploading file ${remoteFilePath}.`, error);
Using the PR code.
this.logger.error(`Error uploading file ${remoteFilePath}.`, error);
this.logger.error(`Error uploading file ${remoteFilePath}.`, error, "SOME CONTEXT");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest the parseJSONError
was a quick implementation from the past to try to print errors and causes recursively.
It can be done in a better way but it is the method that we have right now.
sources/packages/backend/libs/utilities/src/logger/logger.service.ts
Outdated
Show resolved
Hide resolved
try { | ||
this.logger.log(`Uploading ${remoteFilePath}`); | ||
client = await this.getClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @andrewsignori-aot 👍 Thanks for explaining the PR comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes and the log screenshots. Looks good. 👍
Main PR Goal
SFTPIntegrationBase
without disrupting the consumer's methods and try to limit the amount of refactoring.Changes
LoggerService.error
to receive a friendly error and log the error itself, keeping it compatible with the existing methods.SFTPIntegrationBase
. The errors are reshown keeping the current behavior for current method consumers.mais.ts
that was using the log context.SFTPIntegrationBase
method is now generating more logs, the archive operation error handling was adjusted to ensure the exception details are logged.SFTP_ARCHIVE_DIRECTORY
for every archive method.