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

Swap 3853 #389

Merged
merged 3 commits into from
Mar 26, 2024
Merged

Swap 3853 #389

merged 3 commits into from
Mar 26, 2024

Conversation

martin-trajanovski
Copy link
Collaborator

Description

This PR aims to add the configuration for GrayLog logger and do some cleanup

Motivation

There was no logger configured before so we were not able to get any notification if incident happens in this service.

Fixes:

Changes:

  • changes made

Tests included/Docs Updated?

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)
  • Docs updated?
  • New packages used/requires npm install?
  • Toggle added for new features?

Copy link

@Junjiequan Junjiequan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comment, otherwise looks fine to me

Comment on lines +28 to +29
logger.logError(bind + " requires elevated privileges", error);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also include a logger.logeError on line 21

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree!!!

if (!hasAccess) {
logger.logError("Error : ", { statusCode, error });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the extra space intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the spacing. It made sense while I was debugging. Not anymore

Comment on lines 15 to 25
console.log("Request body : ", req.body);
const { hasAccess, statusCode, error, directory, fileNames } = hasFileAccess(
req,
req.body.directory,
req.body.files
);
console.log("Has access : ", hasAccess);
console.log("Status code : ", statusCode);
console.log("Error : ", error);
console.log("Directory : ", directory);
console.log("File names : ", fileNames);
Copy link

@Junjiequan Junjiequan Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should include the logs like so to prevent spam while keeping access logs?

      Logger.logInfo("File accessed", {
        hasAccess: hasAccess,
        statusCode: statusCode,
       error: error,
       directory:directory,
       fileNames:fileNames
      });

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martin-trajanovski can we log that a request has been submitted to this endpoint?
Also, in the log, could we make sure that we list all the files/datasets requested and the user that requested them?

Comment on lines +28 to +29
logger.logError(bind + " requires elevated privileges", error);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree!!!

Comment on lines 15 to 25
console.log("Request body : ", req.body);
const { hasAccess, statusCode, error, directory, fileNames } = hasFileAccess(
req,
req.body.directory,
req.body.files
);
console.log("Has access : ", hasAccess);
console.log("Status code : ", statusCode);
console.log("Error : ", error);
console.log("Directory : ", directory);
console.log("File names : ", fileNames);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martin-trajanovski can we log that a request has been submitted to this endpoint?
Also, in the log, could we make sure that we list all the files/datasets requested and the user that requested them?

if (!hasAccess) {
logger.logError("Error : ", { statusCode, error });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the spacing. It made sense while I was debugging. Not anymore


export const router = express.Router();

/* POST zip */
router.post("/", function(req: express.Request, res: express.Response) {
router.post("/", function (req: express.Request, res: express.Response) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we log the request including the list of files requested?

console.log("Configuration");
console.log(config)

configureLogger(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file the correct place for the logger configuration?
I would put it in the app.ts or index.ts

@nitrosx nitrosx merged commit bb80770 into develop Mar 26, 2024
5 checks passed
@nitrosx nitrosx deleted the swap-3853 branch March 26, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants