pino-pretty icon indicating copy to clipboard operation
pino-pretty copied to clipboard

Allow wildcard for `customPrettifiers` option

Open ankology opened this issue 1 year ago • 1 comments

When not using the nestedKey Pino option, it's hard to figure a way to custom pretty the value log based on coming keys, by example using util.inspect():

customPrettifiers: {      
    //when using a nestedKey option key like 'payload' its easy to perform visual changes, but when log merge the values it's not.
    payload(value) {

        return util.inspect(value, {

            depth: null,
            breakLength: 4,
            colors: true
        });
    },
    //A custom wildcard for any other non-setted keys can be useful
    '*'(value) {

        return util.inspect(value, {

            depth: null,
            breakLength: 4,
            colors: true
        });
    },
},

//Expect foo and other keys to be auto inspected by '*' callback:
logger.info({foo: {bar: {zoo: -1}}});

ankology avatar Jun 13 '23 16:06 ankology

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

jsumners avatar Sep 04 '23 12:09 jsumners