paddle-node-sdk icon indicating copy to clipboard operation
paddle-node-sdk copied to clipboard

[Feature]: Stop polluting stdout (via lots of console.log calls)

Open thomasdondorf opened this issue 11 months ago • 1 comments

Tell us about your feature request

By default, this library is very chatty and prints a lot of actions to console/stdout. This might interfere with other log output and also does not work well together with other logging systems.

Example:

const paddle = new Paddle(process.env.PADDLE_API_KEY, {
    environment: Environment.sandbox,
});
const eventCollection = paddle.events.list();
for await (const event of eventCollection) {
    // do nothing...
}

This leads to the following console output (IDs redacted):

[Paddle] [LOG] [Request] GET https://sandbox-api.paddle.com/events Transaction ID: [...]
[Paddle] [LOG] [Response] GET https://sandbox-api.paddle.com/events 200 Transaction ID: [...] Request ID: [...]
[Paddle] [LOG] [Request] GET https://sandbox-api.paddle.com/events Transaction ID: [...]
[Paddle] [LOG] [Response] GET https://sandbox-api.paddle.com/events 200 Transaction ID: [...] Request ID: [...]
[Paddle] [LOG] [Request] GET https://sandbox-api.paddle.com/events Transaction ID: [...]
[Paddle] [LOG] [Response] GET https://sandbox-api.paddle.com/events 200 Transaction ID: [...] Request ID: [...]
[Paddle] [LOG] [Request] GET https://sandbox-api.paddle.com/events Transaction ID: [...]
[Paddle] [LOG] [Response] GET https://sandbox-api.paddle.com/events 200 Transaction ID: [...] Request ID: [...]
[Paddle] [LOG] [Request] GET https://sandbox-api.paddle.com/events Transaction ID: [...]
[Paddle] [LOG] [Response] GET https://sandbox-api.paddle.com/events 200 Transaction ID: [...] Request ID: [...]

I do not expect other libraries to pollute stdout this much. At least when nothing goes wrong, there should be no output to console by default.

I found no way to disable it, as there is no condition to disable it in the logger class.

What problem are you looking to solve?

It would make sense to disable the console.log calls by default. Instead, some logLevel setting could be provided. Example:

const paddle = new Paddle('...', {
    logLevel: 'verbose' // in this case, the current output would be fine
});

Additional context

No response

How important is this suggestion to you?

Nice to have

thomasdondorf avatar Mar 10 '24 18:03 thomasdondorf