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

feat: Request Logging Customization #4955

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

kdrewes
Copy link

@kdrewes kdrewes commented Aug 4, 2023

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows the [Developer's Certification of Origin]

Hello, I've been working on Im currently working on issue #4463 to customize our log management system. Here are the changes made so far:

• Included a condition in the fastify.js file which dictates whether createRequestLogMessage will be implemented. Here is the condition below:

 if (disableRequestLogging === false) {
        if (createRequestLogMessage) {
          childLogger.info(createRequestLogMessage(req))
        } else {
          childLogger.info({ req: request }, 'incoming request')
        }
      }

• Defined the createRequestLogMessage function in fastify.js
• Added the necessary prototype of createRequestLogMessage in the fastify.d.ts file
• Modified the documentation within docs/Guides/Server.md so that createRequestLogMessage would be included.

Please let me know if you have any questions or concerns regarding this PR. Thank you

Kyle

@kdrewes kdrewes changed the title Kyles branch Request logging customization #4463 Aug 5, 2023
@kdrewes kdrewes changed the title Request logging customization #4463 Request logging customization Aug 5, 2023
@kdrewes kdrewes changed the title Request logging customization Request Logging Customization Aug 5, 2023
@Eomm Eomm linked an issue Aug 5, 2023 that may be closed by this pull request
2 tasks
Copy link
Member

@Eomm Eomm left a comment

Choose a reason for hiding this comment

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

when we will agree on the api, we should add some tests

@@ -1865,6 +1866,7 @@ Currently the properties that can be exposed are:
explicitly passed)
- ignoreTrailingSlash
- disableRequestLogging
- createRequestLogMessage
Copy link
Member

Choose a reason for hiding this comment

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

we should describe its value

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely my apologies for not including that earlier. Is there a particular area within docs/Reference/Server.md where I should include it or does anywhere suffice? Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

search for the docs of disableRequestLogging and put them next to it?

Comment on lines +725 to +729
if (createRequestLogMessage) {
childLogger.info(createRequestLogMessage(req))
} else {
childLogger.info({ req: request }, 'incoming request')
}
Copy link
Member

Choose a reason for hiding this comment

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

instead of executing an if condition in the hot path execution of the request, we could just set a default createRequestLogMessage function to execute it always

Copy link
Author

@kdrewes kdrewes Aug 5, 2023

Choose a reason for hiding this comment

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

Ok sounds good. So instead of having:

 if (createRequestLogMessage) {
          childLogger.info(createRequestLogMessage(req))
        } else {
          childLogger.info({ req: request }, 'incoming request')
        }

Should I just replace that code with:

createRequestLogMessage(childLogger, req)?

Please let me know if I am incorrect about this. Thank you.

Copy link
Member

Choose a reason for hiding this comment

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

If the goal is just to create the message, what about:
createRequestLogMessage(req) and returns a string that is used as the log message.

Or we are trying to cover something else there? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

@kdrewes I was thinking on:

childLogger.info.call(childLogger, createRequestLogMessage(req))

where the default createRequestLogMessage returns: [{ req: request }, 'incoming request']

Note the returned array and the call to avoid to spread the array.

@metcoder95 that usage misses the multiple pino format parameter (the array)

@@ -721,9 +722,12 @@ function fastify (options) {
const reply = new Reply(res, request, childLogger)

if (disableRequestLogging === false) {
childLogger.info({ req: request }, 'incoming request')
if (createRequestLogMessage) {
childLogger.info(createRequestLogMessage(req))
Copy link
Member

Choose a reason for hiding this comment

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

the user here can set only the 1st parameter of childLogger.info.

I would think another way to handle it like:

createRequestLogMessage(childLogger, req)

so it is up to the user choose to log info or warning (i used to change the log level based on the request headers)

Copy link
Author

Choose a reason for hiding this comment

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

Ok perfect! I will make sure to modify the parameters so that createRequestLogMessage will accept childLogger as a parameter.

Copy link
Member

Choose a reason for hiding this comment

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

so it is up to the user choose to log info or warning (i used to change the log level based on the request headers)

Hmm, that's a good one. But then I'd like to know if the initial signature is the best for the use case you describe.
The current issue the PR attempts to solve is to customize the log message only, as per #4463. If that's the goal, I think that it is a matter of just applying the correct order to the log statement. i.e.

Suggested change
childLogger.info(createRequestLogMessage(req))
childLogger.info({ req: request }, createRequestLogMessage(req))

If something more complex is required, I believe the current documentation for disableRequestLogging already covers well what t do in those cases. wdyt? 🙂

@Eomm Eomm added the semver-minor Issue or PR that should land as semver minor label Aug 5, 2023
@Uzlopak Uzlopak changed the title Request Logging Customization feat: Request Logging Customization Aug 5, 2023
@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 5, 2023

Note: Fixed the title and the formatting of the intial comment.

@kdrewes kdrewes closed this Aug 6, 2023
@mcollina
Copy link
Member

mcollina commented Aug 6, 2023

@kdrewes why did you close the PR?

@kdrewes kdrewes reopened this Aug 6, 2023
@kdrewes
Copy link
Author

kdrewes commented Aug 6, 2023

@kdrewes why did you close the PR?

Hi @mcollina, my apologies I must have accidentally closed it by mistake. I made sure to re-open it though.

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Overall, I'm good with the shape is taking, but I believe tests are missing. Should we add some to cover the feature? 🙂

@@ -721,9 +722,12 @@ function fastify (options) {
const reply = new Reply(res, request, childLogger)

if (disableRequestLogging === false) {
childLogger.info({ req: request }, 'incoming request')
if (createRequestLogMessage) {
childLogger.info(createRequestLogMessage(req))
Copy link
Member

Choose a reason for hiding this comment

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

so it is up to the user choose to log info or warning (i used to change the log level based on the request headers)

Hmm, that's a good one. But then I'd like to know if the initial signature is the best for the use case you describe.
The current issue the PR attempts to solve is to customize the log message only, as per #4463. If that's the goal, I think that it is a matter of just applying the correct order to the log statement. i.e.

Suggested change
childLogger.info(createRequestLogMessage(req))
childLogger.info({ req: request }, createRequestLogMessage(req))

If something more complex is required, I believe the current documentation for disableRequestLogging already covers well what t do in those cases. wdyt? 🙂

Comment on lines +725 to +729
if (createRequestLogMessage) {
childLogger.info(createRequestLogMessage(req))
} else {
childLogger.info({ req: request }, 'incoming request')
}
Copy link
Member

Choose a reason for hiding this comment

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

If the goal is just to create the message, what about:
createRequestLogMessage(req) and returns a string that is used as the log message.

Or we are trying to cover something else there? 🤔

@@ -111,6 +111,7 @@ declare namespace fastify {
requestIdLogLabel?: string;
jsonShorthand?: boolean;
genReqId?: (req: RawRequestDefaultExpression<RawServer>) => string,
createRequestLogMessage?: (req: RawRequestDefaultExpression<RawServer>) => string,
Copy link
Member

Choose a reason for hiding this comment

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

I believe it receives the FastifyRequest type instead of http.IncomingMessage, which is from where the RawRequestDefaultExpression<RawServer> is based on

Copy link
Author

Choose a reason for hiding this comment

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

Ok no problem, I will change it to FastifyRequest and have it return a string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it FastifyRequest or the RawRequest?

Copy link
Author

Choose a reason for hiding this comment

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

Here's how I set the prototype:

createRequestLogMessage?: (ChildLoggerOptions: ChildLoggerOptions, FastifyRequest) => string

Please let me know if you guys have any alternative suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it should be FastifyRequest. We already constructed one at the moment we are printing the incoming request log

@kdrewes
Copy link
Author

kdrewes commented Aug 6, 2023

Hello, I've had some difficulties with implementing the suggestions I've been provided with.

In the fastify.d.ts file I've added the changes

createRequestLogMessage?: (ChildLoggerOptions: ChildLoggerOptions, req: FastifyRequest) => string

and in fastify.js I removed

if (createRequestLogMessage) { childLogger.info(createRequestLogMessage(req)) } else { childLogger.info({ req: request }, 'incoming request') }

and replaced it with

createRequestLogMessage(childLogger, req)

However, when I attempted to commit the changes I ran into multiple errors. Please let me know if you have any suggestions on how I can modify these changes. Thank you.

@metcoder95
Copy link
Member

Can you paste the errors you faced?

@kdrewes
Copy link
Author

kdrewes commented Aug 6, 2023

Can you paste the errors you faced?

Yes absolutely. So I altered the syntax so it would state the following:

if (disableRequestLogging === false) { createRequestLogMessage(childLogger, req) }

which did reduce the number of errors I previously was encountering. However I still have one error that I'm coming across. Here's the information on my console. Please let me know if you have any questions

PASS ​ test/bodyLimit.test.js 17 OK 83.82ms
​ PASS ​ test/buffer.test.js 7 OK 51.417ms
​ PASS ​ test/allowUnsafeRegex.test.js 14 OK 118.96ms
​ PASS ​ test/als.test.js 13 OK 34.269ms
​ PASS ​ test/500s.test.js 31 OK 93.334ms
​ PASS ​ test/build/version.test.js 1 OK 15.587ms
​ PASS ​ test/404s.test.js 297 OK 426.374ms
​ PASS ​ test/chainable.test.js 3 OK 43.672ms
​ PASS ​ test/case-insensitive.test.js 18 OK 139.26ms
​ PASS ​ test/childLoggerFactory.test.js 9 OK 123.964ms
​ SKIP ​ test/build/error-serializer.test.js
~ ensure the current error serializer is latest

​ SKIP ​ test/build/error-serializer.test.js 1 skip of 2 824.519ms
~ ensure the current error serializer is latest

​ PASS ​ test/async-await.test.js 81 OK 862.828ms
​ SKIP ​ test/close-pipelining.test.js
~ Should not return 503 while closing - pipelining - return503OnClosing: false, skip Node >= v19.x

​ SKIP ​ test/close-pipelining.test.js 1 skip of 6 194.57ms
~ Should not return 503 while closing - pipelining - return503OnClosing: false, skip Node >= v19.x

​ PASS ​ test/connectionTimeout.test.js 6 OK 77.726ms
​ PASS ​ test/constrained-routes.test.js 76 OK 152.233ms
​ PASS ​ test/content-type.test.js 8 OK 67.23ms
​ SKIP ​ test/close.test.js
~ Current opened connection should continue to work after closing and return "connection: close" header - return503OnClosing:
false, skip Node >= v19.x

​ PASS ​ test/content-length.test.js 22 OK 105.779ms
​ PASS ​ test/copy.test.js 4 OK 45.057ms
​ PASS ​ test/context-config.test.js 27 OK 133.343ms
​ PASS ​ test/content-parser.test.js 98 OK 298.966ms
​ PASS ​ test/custom-http-server.test.js 12 OK 68.424ms
​ PASS ​ test/client-timeout.test.js 1 OK 978.549ms
​ PASS ​ test/custom-parser-async.test.js 7 OK 88.928ms
​ PASS ​ test/custom-querystring-parser.test.js 28 OK 75.504ms
​ PASS ​ test/default-route.test.js 8 OK 52.696ms
​ PASS ​ test/custom-parser.1.test.js 127 OK 337.268ms
​ PASS ​ test/custom-parser.0.test.js 97 OK 371.069ms
​ PASS ​ test/encapsulated-child-logger-factory.test.js 8 OK 46.719ms
​ PASS ​ test/esm/index.test.js 2 OK 25.972ms
​ PASS ​ test/encapsulated-error-handler.test.js 7 OK 44.559ms
​ PASS ​ test/diagnostics-channel.test.js 5 OK 301.465ms
​ PASS ​ test/delete.test.js 43 OK 375.098ms
​ PASS ​ test/decorator.test.js 193 OK 426.426ms
​ PASS ​ test/fastify-instance.test.js 23 OK 185.128ms
​ PASS ​ test/has-route.test.js 8 OK 65.751ms
​ PASS ​ test/handler-context.test.js 9 OK 104.407ms
​ PASS ​ test/genReqId.test.js 13 OK 84.079ms
​ PASS ​ test/head.test.js 17 OK 171.982ms
​ PASS ​ test/get.test.js 53 OK 188.672ms
​ PASS ​ test/fluent-schema.test.js 18 OK 255.926ms
​ PASS ​ test/header-overflow.test.js 6 OK 68.362ms
​ PASS ​ test/http2/head.test.js 3 OK 68.41ms
​ PASS ​ test/hooks-async.test.js 128 OK 319.298ms
​ PASS ​ test/http2/missing-http2-module.test.js 2 OK 20.897ms
​ PASS ​ test/hooks.on-ready.test.js 75 OK 670.232ms
​ PASS ​ test/http2/constraint.test.js 9 OK 269.057ms
​ PASS ​ test/http2/plain.test.js 6 OK 105.178ms
​ PASS ​ test/http2/closing.test.js 9 OK 273.177ms
​ PASS ​ test/http2/unknown-http-method.test.js 3 OK 44.693ms
​ PASS ​ test/imports.test.js 4 OK 135.085ms
​ PASS ​ test/http2/secure.test.js 7 OK 225.129ms
​ PASS ​ test/https/custom-https-server.test.js 4 OK 129.868ms
​ PASS ​ test/https/https.test.js 10 OK 174.04ms
​ PASS ​ test/internals/all.test.js 32 OK 63.182ms
​ PASS ​ test/internals/contentTypeParser.test.js 4 OK 26.165ms
​ PASS ​ test/internals/context.test.js 4 OK 36.319ms
​ PASS ​ test/internals/decorator.test.js 17 OK 21.571ms
​ PASS ​ test/internals/hookRunner.test.js 89 OK 37.687ms
​ PASS ​ test/internals/errors.test.js 622 OK 153.47ms
​ PASS ​ test/internals/hooks.test.js 27 OK 12.448ms
​ PASS ​ test/internals/handleRequest.test.js 32 OK 153.395ms
​ PASS ​ test/internals/plugin.test.js 9 OK 24.143ms
​ PASS ​ test/internals/logger.test.js 40 OK 54.3ms
​ PASS ​ test/inject.test.js 71 OK 1s
​ PASS ​ test/internals/reply-serialize.test.js 103 OK 223.708ms
​ PASS ​ test/internals/initialConfig.test.js 70 OK 169.746ms
​ PASS ​ test/internals/reqIdGenFactory.test.js 10026 OK 362.224ms
​ PASS ​ test/internals/request.test.js 107 OK 58.789ms
​ PASS ​ test/internals/server.test.js 8 OK 79.142ms
​ PASS ​ test/internals/reply.test.js 327 OK 768.708ms
​ PASS ​ test/internals/validation.test.js 39 OK 139.799ms
​ PASS ​ test/keepAliveTimeout.test.js 6 OK 87.73ms
​ PASS ​ test/internals/request-validate.test.js 216 OK 698.473ms
​ PASS ​ test/listen.deprecated.test.js 29 OK 175.858ms
​ PASS ​ test/lock.test.js 5 OK 58.846ms
​ PASS ​ test/listen.test.js 53 OK 180.419ms
​ PASS ​ test/maxRequestsPerSocket.test.js 22 OK 104.683ms
​ PASS ​ test/middleware.test.js 3 OK 35.229ms
​ PASS ​ test/noop-set.test.js 2 OK 7.644ms
​ PASS ​ test/mkcol.test.js 4 OK 47.598ms
​ PASS ​ test/move.test.js 5 OK 44.907ms
​ PASS ​ test/nullable-validation.test.js 18 OK 157.307ms
​ PASS ​ test/output-validation.test.js 24 OK 103.178ms
​ PASS ​ test/options.test.js 69 OK 318.092ms
​ PASS ​ test/options.error-handler.test.js 79 OK 310.984ms
​ PASS ​ test/patch.error-handler.test.js 104 OK 337.512ms
​ PASS ​ test/patch.test.js 80 OK 350.538ms
​ PASS ​ test/pretty-print.test.js 36 OK 97.999ms
​ PASS ​ test/promises.test.js 20 OK 75.227ms
​ SKIP ​ test/close.test.js 1 skip of 82 7s
~ Current opened connection should continue to work after closing and return "connection: close" header - return503OnClosing:
false, skip Node >= v19.x

​ PASS ​ test/plugin.test.js 221 OK 326.558ms
​ PASS ​ test/propfind.test.js 11 OK 70.104ms
​ PASS ​ test/proppatch.test.js 5 OK 65.85ms
​ PASS ​ test/hooks.test.js 592 OK 5s
​ PASS ​ test/proto-poisoning.test.js 21 OK 119.27ms
​ PASS ​ test/register.test.js 31 OK 146.034ms
​ PASS ​ test/reply-code.test.js 8 OK 57.164ms
​ PASS ​ test/put.error-handler.test.js 104 OK 449.089ms
test/reply-trailers.test.js 2> (node:54649) [FSTDEP013] FastifyDeprecation: Direct return of "trailers" function is deprecated.
Please use "callback" or "async-await" for return value. The support of direct return will removed in fastify@5.
test/reply-trailers.test.js 2> (Use node --trace-warnings ... to show where the warning was created)
​ PASS ​ test/put.test.js 80 OK 483.738ms
​ PASS ​ test/request-error.test.js 52 OK 242.306ms
​ PASS ​ test/requestTimeout.test.js 7 OK 72.391ms
​ PASS ​ test/reply-error.test.js 301 OK 486.918ms
​ PASS ​ test/http2/secure-with-fallback.test.js 14 OK 5s
​ PASS ​ test/same-shape.test.js 4 OK 64.157ms
​ PASS ​ test/route-prefix.test.js 89 OK 261.303ms
​ FAIL ​ test/router-options.test.js
✖ test unfinished

test/router-options.test.js
171 | })
172 |

173 | test('Should supply Fastify request to the logger in frameworkErrors wrapper - FST_ERR_BAD_URL', t => {
| ^
174 | t.plan(8)
175 |
176 | const REQ_ID = 'REQ-1234'

test: Should supply Fastify request to the logger in frameworkErrors wrapper -
FST_ERR_BAD_URL
stack: |
Object. (test/router-options.test.js:173:1)

​ FAIL ​ test/router-options.test.js
✖ child test left in queue: t.test Should honor disableRequestLogging option in frameworkErrors wrapper - FST_ERR_BAD_URL

​ FAIL ​ test/router-options.test.js
✖ child test left in queue: t.test Should honor frameworkErrors option - FST_ERR_ASYNC_CONSTRAINT

​ FAIL ​ test/router-options.test.js
✖ child test left in queue: t.test Should supply Fastify request to the logger in frameworkErrors wrapper -
FST_ERR_ASYNC_CONSTRAINT

​ FAIL ​ test/router-options.test.js
✖ child test left in queue: t.test Should honor disableRequestLogging option in frameworkErrors wrapper - FST_ERR_ASYNC_CONSTRAINT

​ FAIL ​ test/router-options.test.js 5 failed of 41 194.77ms
✖ test unfinished
✖ child test left in queue: t.test Should honor disableRequestLogging option in frameworkErrors wrapper - FST_ERR_BAD_URL
✖ child test left in queue: t.test Should honor frameworkErrors option - FST_ERR_ASYNC_CONSTRAINT
✖child test left in queue: t.test Should supply Fastify request to the logger in frameworkErrors wrapper -
FST_ERR_ASYNC_CONSTRAINT
✖ child test left in queue: t.test Should honor disableRequestLogging option in frameworkErrors wrapper - FST_ERR_ASYNC_CONSTRAINT

​ PASS ​ test/schema-examples.test.js 23 OK 325.87ms
test/route.test.js 2> (node:54654) [FSTDEP012] FastifyDeprecation: Request#context property access is deprecated. Please use
"Request#routeConfig" or "Request#routeSchema" instead for accessing Route settings. The "Request#context" will be removed in
fastify@5.
test/route.test.js 2> (Use node --trace-warnings ... to show where the warning was created)
test/route.test.js 2> (node:54654) [FSTDEP012] FastifyDeprecation: Request#context property access is deprecated. Please use
"Request#routeConfig" or "Request#routeSchema" instead for accessing Route settings. The "Request#context" will be removed in
fastify@5.
test/route.test.js 2> (node:54654) [FSTDEP012] FastifyDeprecation: Request#context property access is deprecated. Please use
"Request#routeConfig" or "Request#routeSchema" instead for accessing Route settings. The "Request#context" will be removed in
fastify@5.
​ PASS ​ test/reply-trailers.test.js 110 OK 1s
​ PASS ​ test/route-hooks.test.js 232 OK 1s
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The headers schema for POST: /:id is missing. This may
indicate the schema is not well specified.
test/schema-feature.test.js 2> (Use node --trace-warnings ... to show where the warning was created)
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The body schema for POST: /:id is missing. This may
indicate the schema is not well specified.
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The querystring schema for POST: /:id is missing. This
may indicate the schema is not well specified.
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The params schema for POST: /:id is missing. This may
indicate the schema is not well specified.
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The params schema for GET: /undefinedParams/:id is
missing. This may indicate the schema is not well specified.
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The params schema for HEAD: /undefinedParams/:id is
missing. This may indicate the schema is not well specified.
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The body schema for GET: /undefinedBody/:id is missing.
This may indicate the schema is not well specified.
test/schema-feature.test.js 2> (node:54658) [FSTWRN001] FastifyWarning: The body schema for HEAD: /undefinedBody/:id is missing.
This may indicate the schema is not well specified.
​ PASS ​ test/search.test.js 31 OK 218.864ms
​ PASS ​ test/schema-serialization.test.js 102 OK 454.934ms
​ PASS ​ test/schema-validation.test.js 100 OK 463.457ms
​ PASS ​ test/schema-special-usage.test.js 107 OK 627.687ms
​ PASS ​ test/route.test.js 223 OK 1s
​ PASS ​ test/schema-feature.test.js 217 OK 881.928ms
​ PASS ​ test/serial/logger.0.test.js 145 OK 124.046ms
​ PASS ​ test/serial/logger.1.test.js 103 OK 123.516ms
​ PASS ​ test/type-provider.test.js 2 OK 40.119ms
​ PASS ​ test/sync-routes.test.js 5 OK 100.292ms
​ PASS ​ test/server.test.js 8 OK 94.692ms
​ PASS ​ test/trace.test.js 1 OK 89.974ms
​ PASS ​ test/throw.test.js 38 OK 139.265ms
​ PASS ​ test/trust-proxy.test.js 35 OK 187.172ms
​ SKIP ​ test/stream.test.js
~ should support send module 200 and 404

​ SKIP ​ test/stream.test.js 1 skip of 85 280.882ms
~ should support send module 200 and 404

​ PASS ​ test/unsupported-httpversion.test.js 2 OK 67.034ms
​ PASS ​ test/unlock.test.js 4 OK 80.325ms
​ PASS ​ test/upgrade.test.js 2 OK 51.557ms
​ PASS ​ test/url-rewriting.test.js 21 OK 142.673ms
​ PASS ​ test/wrapThenable.test.js 2 OK 11.456ms
​ PASS ​ test/versioned-routes.test.js 89 OK 178.382ms
​ PASS ​ test/validation-error-handling.test.js 86 OK 284.447ms
​ PASS ​ test/skip-reply-send.test.js 158 OK 10s

🌈 SUMMARY RESULTS 🌈

​ SKIP ​ test/build/error-serializer.test.js 1 skip of 2 824.519ms
~ ensure the current error serializer is latest

​ SKIP ​ test/close-pipelining.test.js 1 skip of 6 194.57ms
~ Should not return 503 while closing - pipelining - return503OnClosing: false, skip Node >= v19.x

​ SKIP ​ test/close.test.js 1 skip of 82 7s
~ Current opened connection should continue to work after closing and return "connection: close" header - return503OnClosing:
false, skip Node >= v19.x

​ FAIL ​ test/router-options.test.js 5 failed of 41 194.77ms
✖ test unfinished
✖ child test left in queue: t.test Should honor disableRequestLogging option in frameworkErrors wrapper - FST_ERR_BAD_URL
✖ child test left in queue: t.test Should honor frameworkErrors option - FST_ERR_ASYNC_CONSTRAINT
✖ child test left in queue: t.test Should supply Fastify request to the logger in frameworkErrors wrapper -
FST_ERR_ASYNC_CONSTRAINT
✖child test left in queue: t.test Should honor disableRequestLogging option in frameworkErrors wrapper -
FST_ERR_ASYNC_CONSTRAINT

​ SKIP ​ test/stream.test.js 1 skip of 85 280.882ms
~ should support send module 200 and 404

Suites: ​1 failed​, ​131 passed​, ​132 of 132 completed​
Asserts: ​​​5 failed​, ​17672 passed​, ​4 skip​, ​of 17681​
​Time:​ ​23s​----------|---------|----------|---------|---------|-------------------

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 0 0 0 0
---------- --------- ---------- --------- --------- -------------------
pre-commit:
pre-commit: We've failed to pass the specified git pre-commit hooks as the test
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit:
pre-commit: git commit -n (or --no-verify)
pre-commit:
pre-commit: This is ill-advised since the commit is broken.
pre-commit:
Kyles-MacBook-Pro:fastify kyledrewes$

@metcoder95
Copy link
Member

Maybe you can try to isolate a single test and see what might be wrong. See tap#only

@kdrewes
Copy link
Author

kdrewes commented Aug 7, 2023

Maybe you can try to isolate a single test and see what might be wrong. See tap#only

Hi @metcoder95, thanks for looking this over for me. What would be able example of isolating a single test so that I can determine the problem? In the meantime, I will continue investigating the matter further. Thank you.

@kdrewes
Copy link
Author

kdrewes commented Aug 8, 2023

Hey guys, I've been experimenting with the code and it appears that the error doesn't appear until I update the following prototype from:
createRequestLogMessage?: (req: RawRequestDefaultExpression) => string
to
(childLoggerOption: childLoggerOption, req: RawRequestDefaultExpression) => string

so just to make sure I'm doing this correctly, when plugging in a childLogger object as a parameter, would "childLoggerOption: childLoggerOption" be the proper argument to use? Also, is it even worth using childLogger as an argument to begin with? Thank you

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

so just to make sure I'm doing this correctly, when plugging in a childLogger object as a parameter, would "childLoggerOption: childLoggerOption" be the proper argument to use? Also, is it even worth using childLogger as an argument to begin with? Thank you

We should be using the childLogger already constructed a few lines back. See my comment about other approach we can also take: https://github.com/fastify/fastify/pull/4955/files#r1285197031

@@ -111,6 +111,7 @@ declare namespace fastify {
requestIdLogLabel?: string;
jsonShorthand?: boolean;
genReqId?: (req: RawRequestDefaultExpression<RawServer>) => string,
createRequestLogMessage?: (req: RawRequestDefaultExpression<RawServer>) => string,
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it should be FastifyRequest. We already constructed one at the moment we are printing the incoming request log

@kdrewes
Copy link
Author

kdrewes commented Aug 14, 2023

Hey guys, I just wanted to let you know I've been caught up with the program I'm enrolled in but will continue working on this as soon as possible. This will not be forgot. Please let me know if you have any questions in the meantime. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request logging customization
5 participants