Skip to content

Make default logger singleton #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Make default logger singleton #199

merged 1 commit into from
Oct 26, 2023

Conversation

kravets-levko
Copy link
Contributor

Fixes #196

When no logger passed to DBSQLClient, the default one is created, a new instance per each client. Even though that default logger only prints to console, it still adds some error listeners to process object. And, as reported in #196, if many DBSQLClients created, there will be too many error listeners attached to process. Another possible issue is that since there are no destructors in JS, we cannot properly cleanup logger when client is no longer needed, and we have to rely on GC.

The proposed solution is to use a single default logger instance for all DBSQLClient instances. The default logger will be created on demand, so if user doesn't need it - they can pass their own logger to every DBSQLClient so default one will never be created.

Signed-off-by: Levko Kravets <levko.ne@gmail.com>
@yunbodeng-db yunbodeng-db merged commit f2955bc into main Oct 26, 2023
@kravets-levko kravets-levko deleted the shared-default-logger branch October 26, 2023 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EventEmitter leaks when many IDBSQLClient objects are created
2 participants