Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update README.md file for flushLogsAndExit function #24

Merged
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update README.md

  • Loading branch information
mostlyjason committed Aug 9, 2017
commit 4caebd2d37def37a8077fa24e65317dc620d3858
@@ -17,7 +17,7 @@ A client implementation for Loggly in node.js. Check out Loggly's [Node logging
// Requiring `winston-loggly-bulk` will expose
// `winston.transports.Loggly`
//
require('winston-loggly-bulk');
require('winston-loggly-bulk');
winston.add(winston.transports.Loggly, options);
```
@@ -56,11 +56,9 @@ bufferOptions: {

## Flush logs and exit

Our library uses ajax requests to send logs to Loggly and ajax requests take time to complete, in that case if you call process.exit() externally in your application then it is certain that as soon as process.exit() will be called, your application will exit and all the queued requests will be interrupted and your application logs will also not reach to Loggly.
Our library uses ajax requests to send logs to Loggly, and as ajax requests take time to complete, logs can be lost when process.exit() is called because it forces an immediate exit. To exit gracefully and ensure that the last logs get to Loggly, we created a function called flushLogsAndExit(). It waits for 10 seconds and then calls process.exit() itself. This allows enough time for the logs to be sent to Loggly.

To support this scenario in which you really want to call process.exit() without losting logs, we have a function called flushLogsAndExit() which waits for 10 seconds and then call process.exit() itself. By doing so, logging will be complete in given time and then your apllication will exit.

You have to do something like below code snippet:
Here is an example of how to use the method:

``` js
var winston = require('winston'),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.