pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

Allow wildcard for `customPrettifiers` option #431

Open ankology opened 1 year ago

ankology commented 1 year ago

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}}});
jsumners commented 1 year ago

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