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

feat: change scope #482

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

medtaher123
Copy link
Contributor

This PR changes the LoggerService scope from singleton to transient. The main motivation for this change is to allow adding context-specific data for each class that uses the LoggerService.By making the service transient, a new instance of LoggerService will be created for each injection, enabling us to set a unique context for logging per class.Implications

  • Pros :

    • Enables class-specific logging contexts, improving traceability and debugging.

    • More flexible for future logging enhancements.

  • Cons :

    • Loss of singleton behavior means there will be multiple instances, potentially increasing memory usage slightly.

@@ -86,7 +86,7 @@ async function bootstrap() {

process.on('uncaughtException', (error) => {
if (error.stack?.toLowerCase().includes('smtp'))
app.get(LoggerService).error('SMTP error', error.stack);
(await app.resolve(LoggerService)).error('SMTP error', error.stack);
Copy link
Contributor

Choose a reason for hiding this comment

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

process.on('uncaughtException', async (error) => {
if (error.stack?.toLowerCase().includes('smtp'))
(await (app.resolve(LoggerService))).error('SMTP error', error.stack);
else throw error;
});

api/src/main.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants