From bb34f92d5ca75f217d7a204a5352a21271ce7d71 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Tue, 10 Dec 2024 13:47:38 +0700 Subject: [PATCH] Update serverless docs --- Serverless/lambda-async.md | 16 +++++++++++++++- Serverless/lambda-sync.md | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Serverless/lambda-async.md b/Serverless/lambda-async.md index bfd3637..5f7a299 100644 --- a/Serverless/lambda-async.md +++ b/Serverless/lambda-async.md @@ -1,4 +1,4 @@ -Example how to use logzio-nodejs inside an async lambda +## Example how to use logzio-nodejs inside an async lambda ``` var logger = require('logzio-nodejs').createLogger({ @@ -24,3 +24,17 @@ exports.handler = async function(event,context) { return context }; ``` + +## Usage with sendAndClose with callback +The `sendAndClose` method can accept a callback function. This method sends any remaining log messages and then closes the logger. The callback function will be called once the remaining messages are sent. + +```javascript +logger.sendAndClose(function(err) { + if (err) { + console.error('Error sending final logs:', err); + } else { + console.log('Final logs sent successfully'); + } +}); +``` +By using the callback option, you can effectively manage and monitor the log transmission process, ensuring that you are aware of any issues or confirming successful log deliveries. \ No newline at end of file diff --git a/Serverless/lambda-sync.md b/Serverless/lambda-sync.md index 9822ebc..2c36a2a 100644 --- a/Serverless/lambda-sync.md +++ b/Serverless/lambda-sync.md @@ -1,4 +1,4 @@ -Example on how to use logzio-nodejs inside a sync lambda +## Example on how to use logzio-nodejs inside a sync lambda ``` var logger = require('logzio-nodejs').createLogger({ @@ -17,3 +17,16 @@ exports.handler = function(event,context,callback) { logger.sendAndClose(callback) }; ``` +## Usage with sendAndClose with callback +The `sendAndClose` method can accept a callback function. This method sends any remaining log messages and then closes the logger. The callback function will be called once the remaining messages are sent. + +```javascript +logger.sendAndClose(function(err) { + if (err) { + console.error('Error sending final logs:', err); + } else { + console.log('Final logs sent successfully'); + } +}); +``` +By using the callback option, you can effectively manage and monitor the log transmission process, ensuring that you are aware of any issues or confirming successful log deliveries. \ No newline at end of file