@gus-eip/loggers 3.7.4 → 3.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,8 @@ export declare class CloudWatchLoggerService implements ILogger {
11
11
  logToCloudWatch(type: string, logObject: any, logStreamName: string): Promise<void>;
12
12
  logStreamExists(logStreamName: string): Promise<boolean>;
13
13
  sendAlerttoTeams(errorMessage: any, errorStack: any, handler: any, input: any, logStreamName: any): Promise<any>;
14
- sendNotificationtoTeams(title: any, summary: any, handler: any, logStreamName: any, isFormattingRequired?: boolean): Promise<any>;
14
+ sendNotificationtoTeams(title: any, summary: any, handler: any, logStreamName: any, isFormattingRequired: boolean, type: any): Promise<any>;
15
15
  log(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, logMessage: any, brand: any, secondaryKey: string, logStreamName: string, entityKeyField: string, entityKey: string, destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
16
16
  error(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, errorMessage: any, brand: any, secondaryKey: string, logStreamName: string, entityKeyField: string, entityKey: string, destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
17
- logAlert(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, logMessage: any, brand: any, secondaryKey: string, logStreamName: string, isAlertFormattingRequired?: boolean, destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
17
+ logAlert(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, logMessage: any, brand: any, secondaryKey: string, logStreamName: string, isAlertFormattingRequired?: boolean, type?: 'INFO' | 'Error', destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
18
18
  }
@@ -136,7 +136,7 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
136
136
  console.error('Error sending message:', error);
137
137
  }
138
138
  }
139
- async sendNotificationtoTeams(title, summary, handler, logStreamName, isFormattingRequired = true) {
139
+ async sendNotificationtoTeams(title, summary, handler, logStreamName, isFormattingRequired = true, type) {
140
140
  console.log('Notification summary', summary);
141
141
  const webhookUrl = this.teamWebhookUrl;
142
142
  const timestamp = new Date().toISOString();
@@ -180,6 +180,10 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
180
180
  name: 'timestamp:',
181
181
  value: timestamp,
182
182
  },
183
+ {
184
+ name: 'type:',
185
+ value: type,
186
+ },
183
187
  {
184
188
  name: '',
185
189
  value: `[Click here for more details](https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logsV2:log-groups/log-group/${this.logGroupName}/log-events/${logStreamName})`,
@@ -254,11 +258,11 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
254
258
  await this.sendAlerttoTeams(errorMessage.message ? errorMessage.message : errorMessage, errorMessage.stack ? errorMessage.stack : errorMessage, component, logObject, encodeURIComponent(logStreamName));
255
259
  }
256
260
  }
257
- async logAlert(correlationId, timestamp, component, source, destination, event, usecase, sourcePayload, destinationPayload, logMessage, brand, secondaryKey, logStreamName, isAlertFormattingRequired, destinationObjectType, destinationObjectId, sourceObjectType, sourceObjectId, destinationResponse) {
261
+ async logAlert(correlationId, timestamp, component, source, destination, event, usecase, sourcePayload, destinationPayload, logMessage, brand, secondaryKey, logStreamName, isAlertFormattingRequired, type, destinationObjectType, destinationObjectId, sourceObjectType, sourceObjectId, destinationResponse) {
258
262
  const logObject = {
259
263
  correlationId,
260
264
  timestamp,
261
- type: 'INFO',
265
+ type: type !== null && type !== void 0 ? type : 'INFO',
262
266
  component,
263
267
  source,
264
268
  destination,
@@ -275,9 +279,9 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
275
279
  sourceObjectId,
276
280
  destinationResponse,
277
281
  };
278
- await this.logToCloudWatch('info', logObject, logStreamName);
282
+ await this.logToCloudWatch((type !== null && type !== void 0 ? type : 'info').toLowerCase(), logObject, logStreamName);
279
283
  if (this.isAlertNeeded) {
280
- await this.sendNotificationtoTeams(logMessage, destinationPayload, component, encodeURIComponent(logStreamName), isAlertFormattingRequired);
284
+ await this.sendNotificationtoTeams(logMessage, destinationPayload, component, encodeURIComponent(logStreamName), isAlertFormattingRequired, (type !== null && type !== void 0 ? type : 'info').toLowerCase());
281
285
  }
282
286
  }
283
287
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gus-eip/loggers",
3
- "version": "3.7.4",
3
+ "version": "3.7.5",
4
4
  "description": "@gus-eip/loggers is a package designed to provide logging functionality for your Node.js applications.",
5
5
  "author": "gus",
6
6
  "readmeFilename": "README.md",