hapi-pino
hapi-pino copied to clipboard
multiple registrations not allowed
Hi,
We have written two custom plugins using hapi-pino for our project written on hapi20 and registered both the plugins with different options. When I am starting the server I am seeing the error hapi-pino is already registered. Any reason why hapi-pino is not supporting multiple registrations?
How can I resolve this issue in my project ? Any help is appreciated, Thanks.
I don't know, I'm not using Hapi anymore :(. I'm not sure this is possible with Hapi.
Hapi docs: https://hapi.dev/api/?v=20.1.0#plugins
You can force the multiple registrations by using once: true when calling server.register()
Using once here won't do the job because if you are setting different options in the two hapi-pino registrations, hapi will only recognize one of those options and apply it to both.
As for why hapi-pino cannot support multiple registrations, the server.decorate('server', 'logger', logger) is to blame for this. The server decoration cannot be defined twice.