ovhemert / pino-datadog

đŸŒČA transport for pino that sends messages to DataDog
MIT License
36 stars 24 forks source link

Option to skip console errors/logs #102

Open edenhermelin opened 3 months ago

edenhermelin commented 3 months ago

🚀 Feature Proposal

We have a use-case of using this library without a need to write any error to the console if writing to DataDog failed due to network issues, and we would prefer to silently ignore this failure instead.

Motivation

Having the following lines inside datadog.js causes the errors to automatically be shown in the console:

        console.error('The previous log have not been saved')
        console.error(`${err.message}\n${err.stack}`)

Example

An example for a workaround can be adding a new option (or re-using the noStdout option from the CLI and checking it before logging here:

      if (!this._options.noStdout) { 
        console.error('The previous log have not been saved')
        console.error(`${err.message}\n${err.stack}`)
      }

If this workaround makes sense to you please let me know and I'll open a PR. (If there is an alternative, I'll be happy to hear 😃 )

thanks!