@aws-amplify/datastore 3.7.7-cloud-logging.9 → 3.7.7-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.
@@ -71142,7 +71142,7 @@ if (typeof window === 'undefined' || (typeof window === "undefined" ? "undefined
71142
71142
  }
71143
71143
 
71144
71144
  var logger = new _Logger__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('AWSCloudWatch');
71145
- var INTERVAL = 30000;
71145
+ var INTERVAL = 10000;
71146
71146
 
71147
71147
  var AWSCloudWatchProvider =
71148
71148
  /** @class */
@@ -71166,8 +71166,7 @@ function () {
71166
71166
 
71167
71167
  this._initialized = true;
71168
71168
  }
71169
- } // public static instance: AWSCloudWatchProvider;
71170
-
71169
+ }
71171
71170
 
71172
71171
  AWSCloudWatchProvider.prototype.getProviderName = function () {
71173
71172
  return AWSCloudWatchProvider.PROVIDER_NAME;
@@ -71440,7 +71439,7 @@ function () {
71440
71439
  };
71441
71440
 
71442
71441
  AWSCloudWatchProvider.prototype.pushLogs = function (logs) {
71443
- logger.debug('pushing log events to Cloudwatch buffer');
71442
+ logger.debug('pushing log events to buffer');
71444
71443
  this._dataTracker.logEvents = this._dataTracker.logEvents.concat(logs);
71445
71444
  };
71446
71445
 
@@ -71854,6 +71853,41 @@ function () {
71854
71853
  });
71855
71854
  };
71856
71855
 
71856
+ AWSCloudWatchProvider.prototype.truncateOversizedEvent = function (event) {
71857
+ var timestamp = event.timestamp,
71858
+ message = event.message;
71859
+ var messageJson;
71860
+
71861
+ try {
71862
+ messageJson = JSON.parse(message);
71863
+ var truncated = JSON.stringify({
71864
+ level: messageJson.level,
71865
+ "class": messageJson["class"],
71866
+ message: messageJson.message.substring(0, 500)
71867
+ });
71868
+
71869
+ if (messageJson.data != null) {
71870
+ truncated['data'] = "OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Truncated: " + JSON.stringify(messageJson.data).substring(0, 500);
71871
+ }
71872
+
71873
+ return {
71874
+ timestamp: timestamp,
71875
+ message: truncated
71876
+ };
71877
+ } catch (error) {
71878
+ logger.warn('Could not minify oversized event', error);
71879
+ var truncated = JSON.stringify({
71880
+ level: 'UNKNOWN',
71881
+ "class": 'Unknown',
71882
+ message: 'OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Could not parse event to truncate'
71883
+ });
71884
+ return {
71885
+ timestamp: timestamp,
71886
+ message: truncated
71887
+ };
71888
+ }
71889
+ };
71890
+
71857
71891
  AWSCloudWatchProvider.prototype._getBufferedBatchOfLogs = function () {
71858
71892
  /**
71859
71893
  * CloudWatch has restrictions on the size of the log events that get sent up.
@@ -71873,7 +71907,9 @@ function () {
71873
71907
  if (eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_EVENT_SIZE"]) {
71874
71908
  var errString = "Log entry exceeds maximum size for CloudWatch logs. Log size: " + eventSize + ". Truncating log message.";
71875
71909
  logger.warn(errString);
71876
- currentEvent.message = currentEvent.message.substring(0, eventSize);
71910
+ currentEvent = this.truncateOversizedEvent(currentEvent);
71911
+ this._dataTracker.logEvents[currentEventIdx] = currentEvent;
71912
+ eventSize = new TextEncoder().encode(currentEvent.message).length + _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_BASE_BUFFER_SIZE"];
71877
71913
  }
71878
71914
 
71879
71915
  if (totalByteSize + eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE"]) break;