@gus-eip/loggers 3.3.5 → 3.3.7
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.
@@ -28,6 +28,7 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
28
28
|
await this.cloudwatch.createLogStream(createParams).promise();
|
29
29
|
}
|
30
30
|
async logToCloudWatch(type, logObject, logStreamName) {
|
31
|
+
const MAX_LOG_EVENT_SIZE = 262144;
|
31
32
|
if (!(await this.logStreamExists(logStreamName))) {
|
32
33
|
await this.createLogStream(logStreamName);
|
33
34
|
}
|
@@ -40,12 +41,16 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
|
|
40
41
|
level: type,
|
41
42
|
date: new Date(),
|
42
43
|
});
|
44
|
+
let logMessage = formattedLog.message;
|
43
45
|
const timestampMillis = formattedLog.timestamp.getTime();
|
46
|
+
while (Buffer.byteLength(logMessage, 'utf-8') > MAX_LOG_EVENT_SIZE) {
|
47
|
+
logMessage = logMessage.slice(0, logMessage.length - 1);
|
48
|
+
}
|
44
49
|
const putParams = {
|
45
50
|
logGroupName: this.logGroupName,
|
46
51
|
logStreamName: logStreamName,
|
47
52
|
logEvents: [{
|
48
|
-
message:
|
53
|
+
message: logMessage,
|
49
54
|
timestamp: timestampMillis
|
50
55
|
}],
|
51
56
|
};
|
package/package.json
CHANGED