@@ -13,7 +13,8 @@ import { SendNotificationDto } from '../dtos/send-notification.dto';
1313import { Notification } from '../../domain/entities/notification.entity' ;
1414import { INotificationStrategy } from '../../domain/interfaces/notification-strategy.interface' ;
1515import { INotificationRepository } from '../../domain/interfaces/notification-repository.interface' ;
16- import { LoggerService } from '../../../logger/services/logger.service' ;
16+ import { LoggerServiceFile } from '../../../logger/services/logger.service.file' ;
17+ import { LoggerServiceDb } from '../../../logger/services/logger.service.db' ;
1718
1819@ApiTags ( 'Notifications' )
1920@Controller ( 'api/notifications' )
@@ -22,7 +23,8 @@ export class NotificationController {
2223 private readonly notificationFactory : NotificationFactory ,
2324 @Inject ( 'INotificationRepository' )
2425 private readonly notificationRepository : INotificationRepository ,
25- private readonly logger : LoggerService ,
26+ private readonly logger : LoggerServiceFile ,
27+ private readonly loggerDb : LoggerServiceDb ,
2628 ) { }
2729
2830 @Post ( )
@@ -61,15 +63,17 @@ export class NotificationController {
6163 // Send notification
6264 const strategy : INotificationStrategy =
6365 this . notificationFactory . createStrategy ( dto . mediaType ) ;
64- console . log ( 'notification strategy is created' ) ;
6566 await strategy . send ( notification ) ;
6667
68+ console . log ( 'notification strategy creation ended' ) ;
69+
6770 // Save notification after successful send
6871 await this . notificationRepository . save ( notification ) ;
6972
7073 // Log successful send
7174 this . logger . log (
7275 `Notification (${ dto . notificationType } ) sent to ${ dto . recipient } via ${ dto . mediaType } ` ,
7376 ) ;
77+ await this . loggerDb . error ( `Exception occurred while sending notification` ) ;
7478 }
7579}
0 commit comments