cat-a-logs 1.1.5 → 1.1.6

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.

Potentially problematic release.


This version of cat-a-logs might be problematic. Click here for more details.

package/client/index.js CHANGED
@@ -41,8 +41,7 @@ exports.catalog = catalog;
41
41
  var logger_1 = require("@aws-lambda-powertools/logger");
42
42
  var ajv_1 = require("ajv");
43
43
  //cache entries are structured thusly: 'Namespace + Dimensions(Alphabetically)': EMFObject
44
- var cache = {};
45
- exports.cache = cache;
44
+ exports.cache = {};
46
45
  //catalog(kilos, "kilos" , "lambda-function-metrics", "Kilograms", {'functionVersion': $LATEST, 'testDimension': derp});
47
46
  function catalog(trackedVariable_1, metricName_1, metricNamespace_1) {
48
47
  return __awaiter(this, arguments, void 0, function (trackedVariable, metricName, metricNamespace, metricUnitLabel, CustomerDefinedDimension, resolution, deploy) {
@@ -54,7 +53,7 @@ function catalog(trackedVariable_1, metricName_1, metricNamespace_1) {
54
53
  if (deploy === void 0) { deploy = false; }
55
54
  return __generator(this, function (_b) {
56
55
  //Check for any errors & validate inputs based on documentations
57
- if (!cache)
56
+ if (!exports.cache)
58
57
  throw new Error('cache is not found, please import cache from cat-a-log');
59
58
  if (Object.keys(CustomerDefinedDimension).concat([metricName.toLowerCase()]).filter(function (el) { return el === "level" || "message" || "sampling_rate" || "service" || "timestamp" || "xray_trace_id"; }).length > 0)
60
59
  throw new Error("metricName, or Dimension names cannot be the same as these native logger keys: level || message || sampling_rate || service || timestamp || xray_trace_id");
@@ -173,10 +172,10 @@ function catalog(trackedVariable_1, metricName_1, metricNamespace_1) {
173
172
  sortedDimensions[Object.keys(CustomerDefinedDimension).sort()[i]] =
174
173
  CustomerDefinedDimension[Object.keys(CustomerDefinedDimension).sort()[i]];
175
174
  }
176
- check = cache["".concat(metricNamespace).concat(sortedDimensions)];
175
+ check = exports.cache["".concat(metricNamespace).concat(sortedDimensions)];
177
176
  if (check != undefined) {
178
177
  //push the metrics object to Metrics array
179
- cache["".concat(metricNamespace).concat(sortedDimensions)]['_aws']['CloudWatchMetrics'][0]['Metrics'].push({
178
+ exports.cache["".concat(metricNamespace).concat(sortedDimensions)]['_aws']['CloudWatchMetrics'][0]['Metrics'].push({
180
179
  Name: metricName,
181
180
  Unit: metricUnitLabel,
182
181
  StorageResolution: resolution,
@@ -218,18 +217,18 @@ function catalog(trackedVariable_1, metricName_1, metricNamespace_1) {
218
217
  throw new Error("Supplied/Proposed structured log does not comply with EMF schema");
219
218
  }
220
219
  // If it passes then add to cache object
221
- cache["".concat(metricNamespace).concat(sortedDimensions)] = newEmfLog;
220
+ exports.cache["".concat(metricNamespace).concat(sortedDimensions)] = newEmfLog;
222
221
  }
223
222
  if (deploy) {
224
223
  //after last catalog function is invoked, send all cached logs with logger at once
225
- for (i = 0; i < Object.keys(cache).length; i++) {
226
- logger.info("Your EMF compliant Structured Metrics Log ".concat(i + 1), cache[Object.keys(cache)[i]]);
224
+ for (i = 0; i < Object.keys(exports.cache).length; i++) {
225
+ logger.info("Your EMF compliant Structured Metrics Log ".concat(i + 1), exports.cache[Object.keys(exports.cache)[i]]);
227
226
  }
228
227
  //clear cache
229
- console.log("BEFORE:", cache);
230
- for (member in cache)
231
- delete cache[member];
232
- console.log("AFTER:", cache);
228
+ console.log("BEFORE:", exports.cache);
229
+ for (member in exports.cache)
230
+ delete exports.cache[member];
231
+ console.log("AFTER:", exports.cache);
233
232
  }
234
233
  return [2 /*return*/];
235
234
  });
package/client/index.ts CHANGED
@@ -5,9 +5,9 @@ import Ajv from 'ajv';
5
5
 
6
6
 
7
7
  //cache entries are structured thusly: 'Namespace + Dimensions(Alphabetically)': EMFObject
8
- const cache: { [key: string]: any } = {};
8
+ export const cache: { [key: string]: any } = {};
9
9
  //catalog(kilos, "kilos" , "lambda-function-metrics", "Kilograms", {'functionVersion': $LATEST, 'testDimension': derp});
10
- async function catalog(
10
+ export async function catalog(
11
11
  trackedVariable: number | Array<number>,
12
12
  metricName: string,
13
13
  metricNamespace: string,
@@ -220,10 +220,6 @@ const validateEmf = ajv.compile(emfSchema);
220
220
  }
221
221
  }
222
222
 
223
- export {
224
- cache,
225
- catalog,
226
- };
227
223
 
228
224
  /*Current Working logger invocation
229
225
  logger.info("Your EMF compliant Structured Metrics Log",
@@ -12,7 +12,7 @@
12
12
  "@aws-lambda-powertools/metrics": "^2.11.0",
13
13
  "lambda-log": "^3.1.0",
14
14
  "ajv": "^8.17.1",
15
- "cat-a-logs": "^1.1.4"
15
+ "cat-a-logs": "^1.1.5"
16
16
  },
17
17
  "scripts": {
18
18
  "test": "mocha tests/unit/"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cat-a-logs",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Create & send structured logs to AWS Cloudwatch logs",
5
5
  "main": "index.js",
6
6
  "exports":{