Skip to content

Commit e35aaae

Browse files
author
mchaudhary
authored
Merge pull request winstonjs#23 from Shwetajain148/expose-helper-method
helper method to call process exit
2 parents c1ad2ee + 4a2770c commit e35aaae

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/winston-loggly.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var events = require('events'),
1717
//
1818
var code = /\u001b\[(\d+(;\d+)*)?m/g;
1919

20+
var timerFunctionForProcessExit = null;
21+
2022
//
2123
// ### function Loggly (options)
2224
// #### @options {Object} Options for this instance.
@@ -62,6 +64,18 @@ var Loggly = exports.Loggly = function (options) {
6264
this.stripColors = options.stripColors || false;
6365
};
6466

67+
//
68+
// Helper function to call process.exit() after waiting
69+
// 10 seconds.
70+
//
71+
var flushLogsAndExit = exports.flushLogsAndExit = function () {
72+
if (timerFunctionForProcessExit === null) {
73+
timerFunctionForProcessExit = setInterval(function () {
74+
process.exit();
75+
},10000);
76+
}
77+
}
78+
6579
//
6680
// Inherit from `winston.Transport`.
6781
//
@@ -72,6 +86,7 @@ util.inherits(Loggly, winston.Transport);
7286
// is available and thus backwards compatible.
7387
//
7488
winston.transports.Loggly = Loggly;
89+
winston.transports.flushLogsAndExit = flushLogsAndExit;
7590

7691
//
7792
// Expose the name of this Transport on the prototype

0 commit comments

Comments
 (0)