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