Skip to content
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

refactor: singleton pattern for logging #47

Merged
merged 7 commits into from
Dec 30, 2024
Merged

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Dec 27, 2024

🤖 Linear

Closes GIT-204

Description

We re-analyzed the multiple instances of Logger and agreed that is best to have a singleton. So we rollbacked to the original solution of a singleton instance and improved its capabilities with a context object to log more information

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

Copy link

linear bot commented Dec 27, 2024

jahabeebs
jahabeebs previously approved these changes Dec 27, 2024
export const createKyselyPostgresDb = (config: DatabaseConfig): Kysely<Database> => {
export const createKyselyPostgresDb = (
config: DatabaseConfig,
logger?: ILogger,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional refactoring suggestion:

When we were working on ebo, Yaco had a nice suggestion to avoid having an optional logger everywhere--you can use the null object design pattern and so if the logger doesn't exist it simply won't log rather than having to handle all the cases it might be null. You can check out the ebo agent repo for the implementation

https://sourcemaking.com/design_patterns/null_object

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooo love this, will implement this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well actually will take it into account when we implement Notifications (as you did in EBO), for the Notification service

@0xnigir1 0xnigir1 merged commit 3b294aa into dev Dec 30, 2024
6 checks passed
@0xnigir1 0xnigir1 deleted the refactor/logging-pattern branch December 30, 2024 13:34
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.

3 participants