questdb / nodejs-questdb-client

QuestDB Node.js Client
35 stars 8 forks source link

Messages in console always visible #12

Closed jalamprea closed 1 year ago

jalamprea commented 1 year ago

I want to use this module, but since it uses console.info to show some messages, it is a little bit slow due to the sync code with console. The debug/info messages should be optional and defined as part of the options when the user create the sender

glasstiger commented 1 year ago

The client prints info level messages only in connect()/close() and that is intentional. Expected the client app to connect to the DB at startup and then hold onto the client until shutdown or until it is not needed anymore. Maybe you create a new client often?

The plan was (and I think still is) to give the option to inject a logger into the client so it can integrate with the host app's logging system. At that point even debug level logging could be added, client could print entire traffic sent to QuestDB if debug level logging is enabled.

glasstiger commented 1 year ago

Probably will merge your pull request for now to get you going and will look into logger integration after that.

glasstiger commented 1 year ago

Just released v1.0.2 which has a new option to pass a custom logging function to the client. This should help. Now you can create a Sender which does not log anything:

const sender = new Sender({bufferSize: 1024, log: () => {}});
glasstiger commented 1 year ago

@jalamprea, closing this issue now. Please, feel free to reopen it if the suggested solution is not satisfactory.