fabulousgk / pino-discord-webhook

A Pino v7+ compatible transport to forward log events to a Discord webhook from a dedicated worker
MIT License
1 stars 1 forks source link

Error while using it with pino.transport #3

Closed PatZab closed 2 months ago

PatZab commented 2 months ago

Hello,

when I use it like this:

const transport = pino.transport({
  targets: [
    {
      target: 'pino-pretty',
      options: {
        colorize: false,
        destination: `logs/${getFormattedDate()}_ssf-bot.log`,
      },
      level: process.env.LOGGING_LEVEL || 'info',
    },
    {
      target: 'pino-pretty',
      level: process.env.LOGGING_LEVEL || 'info',
      options: {
        colorize: true,
      },
    },
    {
      target: 'pino-discord-webhook',
      options: {
        webhookUrl: 'https://discord.com/api/webhooks/....',
      },
    },
  ],
});

export const logger = pino(
  {
    name: 'SSF-Bot',
    level: process.env.LOGGING_LEVEL || 'info',
  },
  transport
);

then it gives me this error:

D:\Storage\Dev-Projects\ssf-bot\node_modules\pino-discord-webhook\dist\index.js:18
        throw new Error('The required option: webhookURL is missing.');
              ^
Error: The required option: webhookURL is missing.
    at discordTransport (D:\Storage\Dev-Projects\ssf-bot\node_modules\pino-discord-webhook\dist\index.js:18:15)
    at D:\Storage\Dev-Projects\ssf-bot\node_modules\pino\lib\worker.js:83:28
    at async Promise.all (index 2)
    at async module.exports (D:\Storage\Dev-Projects\ssf-bot\node_modules\pino\lib\worker.js:81:15)
    at async start (D:\Storage\Dev-Projects\ssf-bot\node_modules\thread-stream\lib\worker.js:67:17)
PatZab commented 2 months ago

Found the problem sorry, I used webhookUrl not webhook URL

fabulousgk commented 2 months ago

That is an easy thing to do!