TypeError when defining custom Pino logger
marcoreni opened this issue · 1 comments
marcoreni commented
Description
I'm trying to define a custom Pino logger in order to customize logs. I'm therefore injecting a pino (v4.17) instance.
I tried using a simple logger: require('pino')()
but I'm receiving an error:
/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/object/index.js:171
target[key] = result.value;
^
TypeError: Cannot assign to read only property 'child' of object '#<EventEmitter>'
at internals.Object._base (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/object/index.js:171:37)
at internals.Object._validate (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/any/index.js:602:37)
at internals.Alternatives._base (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/alternatives/index.js:54:35)
at internals.Alternatives._validate (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/any/index.js:602:37)
at internals.Object._base (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/object/index.js:157:45)
at internals.Object._validate (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/any/index.js:602:37)
at internals.Object._validateWithOptions (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/types/any/index.js:662:29)
at module.exports.internals.Any.root.validate (/usr/src/shared/node_modules/nats-hemera/node_modules/joi/lib/index.js:136:23)
at new Hemera (/usr/src/shared/node_modules/nats-hemera/lib/index.js:69:24)
at new Hemera (/usr/src/shared/src/libs/service/hemera.js:11:1)
(I may be able to workaround by declaring a logger object that calls pino, like:
const logger = {
info: (payload, msg) => customPinoInstance.info(payload, msg),
...
}
But I wouldn't know how to handle child loggers.)
Steps to Reproduce
const hemera = new Hemera(nats, {
logger: require('pino')()
})
Your Environment
- Hemera: 5.8.9
- NodeJs: 8.11.3
- Environment name and version: Alpine Linux on Docker
StarpTech commented
Hi @marcoreni thanks for reporting. I could reproduce it and it's fixed with Hemera 6.