morgan-body icon indicating copy to clipboard operation
morgan-body copied to clipboard

Does not log Request if skip option is used

Open w6e opened this issue 4 years ago • 1 comments

Hi there

When I configure like so:

morganBody(app,  {
  skip: function(req, res) { return res.statusCode < 400 },
}

Then the output looks like

Request Body:
{ ... }
Response Body:
{ ... }
Response: 500 10.371 ms 

When I configure without skip: morganBody(app)

Then the output looks like

Request: POST /api/v1/auth/signup at Sat Jan 16 2021 22:58:37 GMT+0100...
Request Body:
{...}
Response Body:
{...}
Response: 500 10.412 ms 

For some reason Request: POST /api/v1/auth/signup at Sat Jan 16 2021 22:58:37 GMT+0100... does not get logged. Maybe I'm doing something wrong, have you seen this issue before?

Best regards, Felix

w6e avatar Jan 16 '21 22:01 w6e

hmmm I have not, I believe someone else PR'd the skip function, I would need to dig, don't have time right now, there are pretty thorough unit tests you can leverage if you'd like to give it a run @w6e

sirrodgepodge avatar Mar 02 '21 07:03 sirrodgepodge