nextrans-logger 0.1.2 → 0.1.3
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/lib/index.cjs +15 -3
- package/lib/index.js +8 -3
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -54,6 +54,7 @@ class Logging {
|
|
|
54
54
|
return winston_1.format.combine(winston_1.format.errors({ stack: true }), winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston_1.format.printf(this.lineFormat));
|
|
55
55
|
}
|
|
56
56
|
log() {
|
|
57
|
+
var _a, _b, _c, _d;
|
|
57
58
|
const transportsData = [
|
|
58
59
|
new winston_1.transports.Console({ format: this.formatPrint(), handleExceptions: true, level: 'debug' }),
|
|
59
60
|
];
|
|
@@ -74,10 +75,21 @@ class Logging {
|
|
|
74
75
|
this.cloudwatchOption &&
|
|
75
76
|
this.cloudwatchOption.logGroupName &&
|
|
76
77
|
this.cloudwatchOption.logStreamName &&
|
|
77
|
-
this.cloudwatchOption.credentials.secretAccessKey &&
|
|
78
|
-
this.cloudwatchOption.credentials.accessKeyId &&
|
|
78
|
+
((_b = (_a = this === null || this === void 0 ? void 0 : this.cloudwatchOption) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.secretAccessKey) != undefined &&
|
|
79
|
+
((_d = (_c = this === null || this === void 0 ? void 0 : this.cloudwatchOption) === null || _c === void 0 ? void 0 : _c.credentials) === null || _d === void 0 ? void 0 : _d.accessKeyId) != undefined &&
|
|
79
80
|
this.cloudwatchOption.region) {
|
|
80
|
-
const cloudwatch = () =>
|
|
81
|
+
const cloudwatch = () => {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
return new winston_cloudwatch_1.default({
|
|
84
|
+
logGroupName: (_a = this.cloudwatchOption) === null || _a === void 0 ? void 0 : _a.logGroupName,
|
|
85
|
+
logStreamName: (_b = this.cloudwatchOption) === null || _b === void 0 ? void 0 : _b.logStreamName,
|
|
86
|
+
awsOptions: {
|
|
87
|
+
region: (_c = this.cloudwatchOption) === null || _c === void 0 ? void 0 : _c.region,
|
|
88
|
+
credentials: (_d = this === null || this === void 0 ? void 0 : this.cloudwatchOption) === null || _d === void 0 ? void 0 : _d.credentials
|
|
89
|
+
},
|
|
90
|
+
messageFormatter: this.lineFormat,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
81
93
|
log.add(cloudwatch());
|
|
82
94
|
}
|
|
83
95
|
return log;
|
package/lib/index.js
CHANGED
|
@@ -72,11 +72,16 @@ export default class Logging {
|
|
|
72
72
|
this.cloudwatchOption &&
|
|
73
73
|
this.cloudwatchOption.logGroupName &&
|
|
74
74
|
this.cloudwatchOption.logStreamName &&
|
|
75
|
-
this
|
|
76
|
-
this
|
|
75
|
+
this?.cloudwatchOption?.credentials?.secretAccessKey != undefined &&
|
|
76
|
+
this?.cloudwatchOption?.credentials?.accessKeyId != undefined &&
|
|
77
77
|
this.cloudwatchOption.region) {
|
|
78
78
|
const cloudwatch = () => new WinstonCloudwatch({
|
|
79
|
-
|
|
79
|
+
logGroupName: this.cloudwatchOption?.logGroupName,
|
|
80
|
+
logStreamName: this.cloudwatchOption?.logStreamName,
|
|
81
|
+
awsOptions: {
|
|
82
|
+
region: this.cloudwatchOption?.region,
|
|
83
|
+
credentials: this?.cloudwatchOption?.credentials
|
|
84
|
+
},
|
|
80
85
|
messageFormatter: this.lineFormat,
|
|
81
86
|
});
|
|
82
87
|
log.add(cloudwatch());
|