Skip to content

Commit cedc7da

Browse files
authored
Merge pull request #29 from JoHuang/feat/add-close-method
Feat/add close method & fix confusing option
2 parents 024f508 + 5d23ccf commit cedc7da

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class LokiTransport extends Transport {
2222
host: options.host,
2323
interval: options.interval,
2424
json: options.json,
25-
batching: !options.batching,
25+
batching: options.batching !== false,
2626
clearOnError: options.clearOnError,
2727
replaceOnError: options.replaceOnError,
2828
replaceTimestamp: options.replaceTimestamp,
29-
gracefulShutdown: !options.gracefulShutdown
29+
gracefulShutdown: options.gracefulShutdown !== false
3030
})
3131

3232
this.useCustomFormat = options.format !== undefined
@@ -90,6 +90,15 @@ class LokiTransport extends Transport {
9090
// Trigger the optional callback
9191
callback()
9292
}
93+
94+
/**
95+
* Send batch to loki when clean up
96+
*/
97+
close () {
98+
this.batcher.sendBatchToLoki()
99+
.then(() => {}) // maybe should emit something here
100+
.catch(() => {}) // maybe should emit something here
101+
}
93102
}
94103

95104
module.exports = LokiTransport

0 commit comments

Comments
 (0)