PaddleHQ / paddle-node-sdk

Node.js SDK for working with the Paddle API in server-side apps.
https://developer.paddle.com/
Apache License 2.0
41 stars 6 forks source link

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

Closed thomasdondorf closed 3 months ago

thomasdondorf commented 7 months ago

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

vijayasingam-paddle commented 6 months ago

Hi @thomasdondorf, Thank you for sharing this feedback. I agree, our logging strategy is not the best and can be improved.

We will discuss about this internally and update our implementation.

Thank you.

origranot commented 4 months ago

A huge thumbs up, this is so annoying @vijayasingam-paddle any update on that?

vijayasingam-paddle commented 3 months ago

Hi @origranot,

I am sorry for the delay. Fixing the logging strategy is on our radar. We had some other priorities, so this moved below them.

I will share an update once it is ready.

vijayasingam-paddle commented 3 months ago

Hi @thomasdondorf / @origranot,

Thank you for being patient while we fix this problem. I have released a new version(1.4.0) with an option to pass a logLevel in the options while initializing Paddle.

It is defaulted to verbose to avoid surprising anyone already using the SDK. Please change this to error or none based on your needs.

In the next major release, I will update the default value to error so that it goes away for everyone.

Please reach out to us if you need any other help.

Thank you.