@gus-eip/loggers 3.7.3 → 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.
- package/dist/cloudwatch.logger.d.ts +2 -2
- package/dist/cloudwatch.logger.js +30 -15
- package/dist/enum.js +2 -2
- package/dist/module.js +2 -2
- package/package.json +1 -1
@@ -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
|
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,18 +136,29 @@ 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();
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
143
|
+
let headers;
|
144
|
+
let headerRow;
|
145
|
+
let separatorRow;
|
146
|
+
let rows;
|
147
|
+
let formattedSummary;
|
148
|
+
if (isFormattingRequired) {
|
149
|
+
headers = Object.keys(summary[0]);
|
150
|
+
headerRow = `| ${headers.join(' | ')} |`;
|
151
|
+
separatorRow = `| ${headers.map(() => '---').join(' | ')} |`;
|
152
|
+
rows = summary
|
153
|
+
.map((item) => `| ${headers.map((header) => item[header] || '').join(' | ')} |`)
|
154
|
+
.join('\n');
|
155
|
+
formattedSummary = [headerRow, separatorRow, rows].join('\n');
|
156
|
+
}
|
157
|
+
const summaryMsg = isFormattingRequired
|
158
|
+
? formattedSummary
|
159
|
+
: typeof summary === 'object'
|
160
|
+
? JSON.stringify(summary)
|
161
|
+
: summary;
|
151
162
|
const alertMessage = {
|
152
163
|
'@type': 'MessageCard',
|
153
164
|
'@context': 'http://schema.org/extensions',
|
@@ -169,6 +180,10 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
169
180
|
name: 'timestamp:',
|
170
181
|
value: timestamp,
|
171
182
|
},
|
183
|
+
{
|
184
|
+
name: 'type:',
|
185
|
+
value: type,
|
186
|
+
},
|
172
187
|
{
|
173
188
|
name: '',
|
174
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})`,
|
@@ -243,11 +258,11 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
243
258
|
await this.sendAlerttoTeams(errorMessage.message ? errorMessage.message : errorMessage, errorMessage.stack ? errorMessage.stack : errorMessage, component, logObject, encodeURIComponent(logStreamName));
|
244
259
|
}
|
245
260
|
}
|
246
|
-
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) {
|
247
262
|
const logObject = {
|
248
263
|
correlationId,
|
249
264
|
timestamp,
|
250
|
-
type: 'INFO',
|
265
|
+
type: type !== null && type !== void 0 ? type : 'INFO',
|
251
266
|
component,
|
252
267
|
source,
|
253
268
|
destination,
|
@@ -264,14 +279,14 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
264
279
|
sourceObjectId,
|
265
280
|
destinationResponse,
|
266
281
|
};
|
267
|
-
await this.logToCloudWatch('info', logObject, logStreamName);
|
282
|
+
await this.logToCloudWatch((type !== null && type !== void 0 ? type : 'info').toLowerCase(), logObject, logStreamName);
|
268
283
|
if (this.isAlertNeeded) {
|
269
|
-
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());
|
270
285
|
}
|
271
286
|
}
|
272
287
|
};
|
273
|
-
|
274
|
-
exports.CloudWatchLoggerService = CloudWatchLoggerService = __decorate([
|
288
|
+
CloudWatchLoggerService = __decorate([
|
275
289
|
(0, common_1.Injectable)(),
|
276
290
|
__metadata("design:paramtypes", [String, String, String, Boolean])
|
277
291
|
], CloudWatchLoggerService);
|
292
|
+
exports.CloudWatchLoggerService = CloudWatchLoggerService;
|
package/dist/enum.js
CHANGED
@@ -312,7 +312,7 @@ let LoggerEnum = class LoggerEnum {
|
|
312
312
|
};
|
313
313
|
}
|
314
314
|
};
|
315
|
-
|
316
|
-
exports.LoggerEnum = LoggerEnum = __decorate([
|
315
|
+
LoggerEnum = __decorate([
|
317
316
|
(0, common_1.Injectable)()
|
318
317
|
], LoggerEnum);
|
318
|
+
exports.LoggerEnum = LoggerEnum;
|
package/dist/module.js
CHANGED
@@ -28,7 +28,7 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
28
28
|
};
|
29
29
|
}
|
30
30
|
};
|
31
|
-
|
32
|
-
exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
|
31
|
+
LoggerModule = LoggerModule_1 = __decorate([
|
33
32
|
(0, common_1.Module)({})
|
34
33
|
], LoggerModule);
|
34
|
+
exports.LoggerModule = LoggerModule;
|
package/package.json
CHANGED