@aws-amplify/core 4.3.15-cloud-logging.9 → 4.3.15-cloud-logging.10

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.
@@ -33015,7 +33015,7 @@ if (typeof window === 'undefined' || (typeof window === "undefined" ? "undefined
33015
33015
  }
33016
33016
 
33017
33017
  var logger = new _Logger__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('AWSCloudWatch');
33018
- var INTERVAL = 30000;
33018
+ var INTERVAL = 10000;
33019
33019
 
33020
33020
  var AWSCloudWatchProvider =
33021
33021
  /** @class */
@@ -33039,8 +33039,7 @@ function () {
33039
33039
 
33040
33040
  this._initialized = true;
33041
33041
  }
33042
- } // public static instance: AWSCloudWatchProvider;
33043
-
33042
+ }
33044
33043
 
33045
33044
  AWSCloudWatchProvider.prototype.getProviderName = function () {
33046
33045
  return AWSCloudWatchProvider.PROVIDER_NAME;
@@ -33313,7 +33312,7 @@ function () {
33313
33312
  };
33314
33313
 
33315
33314
  AWSCloudWatchProvider.prototype.pushLogs = function (logs) {
33316
- logger.debug('pushing log events to Cloudwatch buffer');
33315
+ logger.debug('pushing log events to buffer');
33317
33316
  this._dataTracker.logEvents = this._dataTracker.logEvents.concat(logs);
33318
33317
  };
33319
33318
 
@@ -33727,6 +33726,41 @@ function () {
33727
33726
  });
33728
33727
  };
33729
33728
 
33729
+ AWSCloudWatchProvider.prototype.truncateOversizedEvent = function (event) {
33730
+ var timestamp = event.timestamp,
33731
+ message = event.message;
33732
+ var messageJson;
33733
+
33734
+ try {
33735
+ messageJson = JSON.parse(message);
33736
+ var truncated = JSON.stringify({
33737
+ level: messageJson.level,
33738
+ "class": messageJson["class"],
33739
+ message: messageJson.message.substring(0, 500)
33740
+ });
33741
+
33742
+ if (messageJson.data != null) {
33743
+ truncated['data'] = "OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Truncated: " + JSON.stringify(messageJson.data).substring(0, 500);
33744
+ }
33745
+
33746
+ return {
33747
+ timestamp: timestamp,
33748
+ message: truncated
33749
+ };
33750
+ } catch (error) {
33751
+ logger.warn('Could not minify oversized event', error);
33752
+ var truncated = JSON.stringify({
33753
+ level: 'UNKNOWN',
33754
+ "class": 'Unknown',
33755
+ message: 'OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Could not parse event to truncate'
33756
+ });
33757
+ return {
33758
+ timestamp: timestamp,
33759
+ message: truncated
33760
+ };
33761
+ }
33762
+ };
33763
+
33730
33764
  AWSCloudWatchProvider.prototype._getBufferedBatchOfLogs = function () {
33731
33765
  /**
33732
33766
  * CloudWatch has restrictions on the size of the log events that get sent up.
@@ -33746,7 +33780,9 @@ function () {
33746
33780
  if (eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_EVENT_SIZE"]) {
33747
33781
  var errString = "Log entry exceeds maximum size for CloudWatch logs. Log size: " + eventSize + ". Truncating log message.";
33748
33782
  logger.warn(errString);
33749
- currentEvent.message = currentEvent.message.substring(0, eventSize);
33783
+ currentEvent = this.truncateOversizedEvent(currentEvent);
33784
+ this._dataTracker.logEvents[currentEventIdx] = currentEvent;
33785
+ eventSize = new TextEncoder().encode(currentEvent.message).length + _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_BASE_BUFFER_SIZE"];
33750
33786
  }
33751
33787
 
33752
33788
  if (totalByteSize + eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE"]) break;