@gus-eip/loggers 2.0.0 → 3.1.0

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.
@@ -17,11 +17,10 @@ class CloudWatchEventFormatter {
17
17
  };
18
18
  }
19
19
  formatLog(item) {
20
- console.log('hereeeee', item.meta);
21
20
  const meta = this.isEmpty(item.meta)
22
21
  ? ''
23
22
  : ' ' + JSON.stringify(item.meta, null, 2);
24
- return `[${item.level.toUpperCase()}] ${item.message}${meta}`;
23
+ return `${meta}`;
25
24
  }
26
25
  isEmpty(value) {
27
26
  if (Array.isArray(value)) {
@@ -8,6 +8,6 @@ export declare class CloudWatchLoggerService implements ILogger {
8
8
  createLogStream(logStreamName: string): Promise<any>;
9
9
  logToCloudWatch(type: string, logObject: any, logStreamName: string): Promise<void>;
10
10
  logStreamExists(logStreamName: string): Promise<boolean>;
11
- log(requestedId: string, message: any, event: string, statusCode: number, details: any, brand: any, logStreamName: string): Promise<any>;
12
- error(requestedId: string, message: any, event: string, errorCode: string, statusCode: number, details: any, brand: any, logStreamName: string): Promise<any>;
11
+ log(requestedId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, source_payload: any, destination_payload: any, logMessage: any, brand: any, secondary_key: string, destination_ObjectType: string, destination_ObjectId: string, source_ObjectType: string, source_ObjectId: string, logStreamName: string): Promise<any>;
12
+ error(requestedId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, source_payload: any, destination_payload: any, errorMessage: any, brand: any, secondary_key: string, destination_ObjectType: string, destination_ObjectId: string, source_ObjectType: string, source_ObjectId: string, logStreamName: string): Promise<any>;
13
13
  }
@@ -13,7 +13,7 @@ exports.CloudWatchLoggerService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const aws_sdk_1 = require("aws-sdk");
15
15
  const cloudwatch_event_formatter_1 = require("./cloudwatch.event.formatter");
16
- let CloudWatchLoggerService = exports.CloudWatchLoggerService = class CloudWatchLoggerService {
16
+ let CloudWatchLoggerService = class CloudWatchLoggerService {
17
17
  constructor(region, logGroupName) {
18
18
  this.version = 'v1';
19
19
  this.cloudwatch = new aws_sdk_1.CloudWatchLogs({ region: region });
@@ -72,33 +72,53 @@ let CloudWatchLoggerService = exports.CloudWatchLoggerService = class CloudWatch
72
72
  throw error;
73
73
  }
74
74
  }
75
- async log(requestedId, message, event, statusCode, details, brand, logStreamName) {
75
+ async log(requestedId, timestamp, component, source, destination, event, usecase, source_payload, destination_payload, logMessage, brand, secondary_key, destination_ObjectType, destination_ObjectId, source_ObjectType, source_ObjectId, logStreamName) {
76
76
  const logObject = {
77
77
  requestedId,
78
- message,
78
+ timestamp,
79
79
  type: 'INFO',
80
+ component,
81
+ source,
82
+ destination,
80
83
  event,
81
- statusCode,
82
- details,
84
+ usecase,
85
+ source_payload,
86
+ destination_payload,
87
+ logMessage,
83
88
  brand,
89
+ secondary_key,
90
+ destination_ObjectType,
91
+ destination_ObjectId,
92
+ source_ObjectType,
93
+ source_ObjectId
84
94
  };
85
95
  await this.logToCloudWatch('info', logObject, logStreamName);
86
96
  }
87
- async error(requestedId, message, event, errorCode, statusCode, details, brand, logStreamName) {
97
+ async error(requestedId, timestamp, component, source, destination, event, usecase, source_payload, destination_payload, errorMessage, brand, secondary_key, destination_ObjectType, destination_ObjectId, source_ObjectType, source_ObjectId, logStreamName) {
88
98
  const logObject = {
89
99
  requestedId,
90
- message,
100
+ timestamp,
91
101
  type: 'Error',
102
+ component,
103
+ source,
104
+ destination,
92
105
  event,
93
- errorCode,
94
- statusCode,
95
- details,
106
+ usecase,
107
+ source_payload,
108
+ destination_payload,
109
+ errorMessage,
96
110
  brand,
111
+ secondary_key,
112
+ destination_ObjectType,
113
+ destination_ObjectId,
114
+ source_ObjectType,
115
+ source_ObjectId
97
116
  };
98
117
  await this.logToCloudWatch('error', logObject, logStreamName);
99
118
  }
100
119
  };
101
- exports.CloudWatchLoggerService = CloudWatchLoggerService = __decorate([
120
+ CloudWatchLoggerService = __decorate([
102
121
  (0, common_1.Injectable)(),
103
122
  __metadata("design:paramtypes", [String, String])
104
123
  ], CloudWatchLoggerService);
124
+ exports.CloudWatchLoggerService = CloudWatchLoggerService;
@@ -1,4 +1,4 @@
1
1
  export interface ILogger {
2
- log(requestedId: string, logMessage: any, event: string, statusCode: number, details: any, brand: any, logStreamName: string): Promise<any>;
3
- error(requestedId: string, errorMessage: any, event: string, errorCode: string, statusCode: number, details: any, brand: any, logStreamName: string): Promise<any>;
2
+ log(requestedId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, source_payload: string, destination_payload: string, logMessage: any, brand: any, secondary_key: string, destination_ObjectType: string, destination_ObjectId: string, source_ObjectType: string, source_ObjectId: string, logStreamName: string): Promise<any>;
3
+ error(requestedId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, source_payload: string, destination_payload: string, errorMessage: any, brand: any, secondary_key: string, destination_ObjectType: string, destination_ObjectId: string, source_ObjectType: string, source_ObjectId: string, logStreamName: string): Promise<any>;
4
4
  }
package/dist/module.js CHANGED
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.LoggerModule = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
12
  const cloudwatch_logger_1 = require("./cloudwatch.logger");
13
- let LoggerModule = exports.LoggerModule = LoggerModule_1 = class LoggerModule {
13
+ let LoggerModule = LoggerModule_1 = class LoggerModule {
14
14
  static forRoot(params) {
15
15
  const cloudwatchProvider = {
16
16
  provide: params.options,
@@ -27,6 +27,7 @@ let LoggerModule = exports.LoggerModule = LoggerModule_1 = class LoggerModule {
27
27
  };
28
28
  }
29
29
  };
30
- exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
30
+ LoggerModule = LoggerModule_1 = __decorate([
31
31
  (0, common_1.Module)({})
32
32
  ], LoggerModule);
33
+ exports.LoggerModule = LoggerModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gus-eip/loggers",
3
- "version": "2.0.0",
3
+ "version": "3.1.0",
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",