Skip to content

Commit

Permalink
Update serverless docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yotamloe committed Dec 10, 2024
1 parent d12a624 commit bb34f92
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
16 changes: 15 additions & 1 deletion Serverless/lambda-async.md
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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.
15 changes: 14 additions & 1 deletion Serverless/lambda-sync.md
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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.

0 comments on commit bb34f92

Please sign in to comment.