pinojs / pino-pretty

🌲Basic prettifier for Pino log lines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow wildcard for `customPrettifiers` option

ankology opened this issue · 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}}});

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