pinojs / pino-pretty

🌲Basic prettifier for Pino log lines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use transport with nestjs?

boris-jenicek opened this issue · comments

tried:
target: require.resolve('./pino-pretty-transport'),
got:
[Nest] 33251 - 12/30/2023, 3:19:40 PM ERROR [ExceptionHandler] The "path" argument must be of type string. Received type number (40)

tried:
target: './pino-pretty-transport',
got:
[Nest] 33330 - 12/30/2023, 3:21:36 PM ERROR [ExceptionHandler] unable to determine transport target for "./pino-pretty-transport" Error: unable to determine transport target for "./pino-pretty-transport"

pino-pretty-transport.js

const pinoPretty = require('pino-pretty');

module.exports = function pinoPrettyTransport(opts) {
  return pinoPretty({
    ...opts,
    messageFormat(log, messageKey, levelLabel) {
      if (log.req)
        return `${log.req.method} ${log.req.url} - ${log.responseTime}ms`;
      return `${log.msg}`;
    },
  });
};

Thanks for reporting. We do not have the resources to support Nest.js users. Please refer to the Nest Discord channel (support) for such questions.