cat-a-logs 2.0.5 → 2.0.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.
- package/README.md +2 -9
- package/client/index.ts +18 -1
- package/package.json +2 -2
package/README.md
CHANGED
@@ -32,7 +32,7 @@ EMF is a JSON specification that enables CloudWatch Logs to automatically extrac
|
|
32
32
|
Your chosen Integrated Development Environment (i.e. VS Code) must already be connected to AWS Lambda. For more guidance on setting up AWS Lambda we recommend following this helpful tutorial from AWS: <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html" target="_blank">Deploy Hello World Application with AWS SAM</a>
|
33
33
|
|
34
34
|
**Installation:**
|
35
|
-
1. Install our package using the command `npm install cat-a-logs` then import the
|
35
|
+
1. Install our package using the command `npm install cat-a-logs` then import the functions into your js file that connects to AWS Lambda `import { deployCatalog, catalog } from "cat-a-logs/index.js";` Check out Cat-A-Log on npm using the attached link:
|
36
36
|
<a href="https://www.npmjs.com/package/cat-a-logs?activeTab=readme" target="_blank">Cat-A-Log</a>
|
37
37
|
|
38
38
|
2. Now enter your arguments into the catalog function! Let's go through each parameter one at a time and see what this looks like. First let's take a look at the function definition:
|
@@ -95,14 +95,7 @@ Your chosen Integrated Development Environment (i.e. VS Code) must already be co
|
|
95
95
|
|
96
96
|
|
97
97
|
4. ON the very last function call - it is important to change the deploy parameter to `true`.
|
98
|
-
|
99
|
-
function catalog(
|
100
|
-
.
|
101
|
-
.
|
102
|
-
.
|
103
|
-
.
|
104
|
-
deploy: boolean = true)
|
105
|
-
```
|
98
|
+
- Alternative approach is to deploy your Lambda function with the `deployCatalog()` function call. This will automatically publish to CloudWatch without the need to use the entire arguments required in Cat-A-Log. Place `deployCatalog()` after you last catalog function call.
|
106
99
|
|
107
100
|
5. Deploy your code with AWS SAM. This will place the file in AWS Lambda waiting for invocation. If you would like to learn more about deploying with SAM please follow the attached
|
108
101
|
<a href= "https://docs.aws.amazon.com/lambda/latest/dg/testing-functions.html" target="_blank">link</a>
|
package/client/index.ts
CHANGED
@@ -235,4 +235,21 @@ async function catalog(
|
|
235
235
|
console.log("AFTER:", cache);
|
236
236
|
}
|
237
237
|
}
|
238
|
-
|
238
|
+
|
239
|
+
//If you want to manually deploy the cache without writing a catalog for it
|
240
|
+
async function deployCatalog() {
|
241
|
+
//Create a new instance of Logger
|
242
|
+
const logger = new Logger({ serviceName: "serverlessAirline" });
|
243
|
+
//Log all cached objects to Cloudwatch through Lambda
|
244
|
+
for (let i = 0; i < Object.keys(cache).length; i++) {
|
245
|
+
logger.info(
|
246
|
+
`Your EMF compliant Structured Metrics Log ${i + 1}`,
|
247
|
+
cache[Object.keys(cache)[i]]
|
248
|
+
);
|
249
|
+
}
|
250
|
+
//clear cache after logging all cached objects to Lambda
|
251
|
+
console.log("BEFORE:", JSON.stringify(cache, null, 2));
|
252
|
+
for (var member in cache) delete cache[member];
|
253
|
+
console.log("AFTER:", cache);
|
254
|
+
}
|
255
|
+
export { cache, catalog, deployCatalog };
|
package/package.json
CHANGED