-
Notifications
You must be signed in to change notification settings - Fork 61
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
Unable to log a "request" event while using "response.failaction" settings as "log" instead of throwing an error. #80
Comments
What will be the best course of action to fix this? |
request
event when using response.failaction
set to log instead of throw an error..
I believe we have the following options:
I would prefer the last approach. Let me know if you agree or have a different approach and then I could help to provide the PR for that. |
the latter would be be better for me
Il giorno mar 9 lug 2019 alle 18:06 Felipe Vieira Almeida <
[email protected]> ha scritto:
… What will be the best course of action to fix this?
I believe we have the following options:
-
we can programmatically add more "internal" options tags to be logged,
not only the accept-encoding
-
we can include the internal options tags as part of the configuration
object
I would prefer the last approach.
Let me know if you agree or have a different approach and then I could
help to provide the PR for that.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#80>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAMXY4EQO2CG35EFPPBHJ3P6SZO3ANCNFSM4H7ADHWA>
.
|
@fvalmeida curious if you ever tried this out? Or if you found an alternative way to log validation errors? I also require the same functionality and am willing to have a go raising a PR for this, if you no longer have the time or need for it. |
If anyone else stumbles onto this, the following works to get these errors logged: server.events.on('request', (event, tags) => {
if (tags.channel = 'internal') {
server.logger.error({req: event.raw.req, err: tags.error, tags:tags.tags}, tags.error.message);
}
}); |
Would you like to send a Pull Request to address this issue? Remember to add unit tests. |
Hapi allows you to choose what to do when response validation fails by setting response.failAction. (ref.: https://hapijs.com/tutorials/validation#failaction)
When we set that option to:
the current way that
hapi-pino
is set to log requests which have theevent.channel
set tointernal
doesn't recognizes that configuration and the log message is ignored.This is where Hapi check for the response.failAction settings
node_modules/@hapi/hapi/lib/toolkit.js
This is where Hapi creates a log payload using the internal channel
node_modules/@hapi/hapi/lib/request.js
This is where
hapi-pino
is ignoring the log message:node_modules/hapi-pino/index.js
The text was updated successfully, but these errors were encountered: