Skip to content

Add support to inject BI logger to our LogService #2434

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 2 commits into from
Jan 30, 2023

Conversation

ethanshar
Copy link
Collaborator

Description

I refactored our LogService to be a Class
And also added support to inject a generic BI logger. This is order to support BI events in our components

Changelog

Support injecting a BI logger in our LogService

@ethanshar
Copy link
Collaborator Author

@M-i-k-e-l Can you please review this one, it's pretty small. I'd like to push this forward.. 🙏

Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l left a comment

Choose a reason for hiding this comment

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

Approved with a saggestion

console.warn(message);
}
interface BILogger {
log: (event: any) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this to be any?
We can make it generic with the following:

interface BILogger<T> {
  log: (event: T) => void;
}
class LogService<T = any> {
  biLogger: BILogger<T> | undefined;

  injectBILogger = (biLogger: BILogger<T>) => {
    this.biLogger = biLogger;
  };

  biLog = (event: T) => {
    this.biLogger?.log(event);
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How would that work? Since I export this class as a singleton there's no where to set the LogService generic type. No?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Very true, did not find a different way to do it...

@M-i-k-e-l M-i-k-e-l merged commit 4f4ed0a into master Jan 30, 2023
@ethanshar ethanshar deleted the infra/LogService_biLogger branch April 2, 2024 06:39
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.

2 participants