Skip to content

Commit

Permalink
Merge pull request #29 from JoHuang/feat/add-close-method
Browse files Browse the repository at this point in the history
Feat/add close method & fix confusing option
  • Loading branch information
JaniAnttonen authored Feb 13, 2020
2 parents 024f508 + 5d23ccf commit cedc7da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class LokiTransport extends Transport {
host: options.host,
interval: options.interval,
json: options.json,
batching: !options.batching,
batching: options.batching !== false,
clearOnError: options.clearOnError,
replaceOnError: options.replaceOnError,
replaceTimestamp: options.replaceTimestamp,
gracefulShutdown: !options.gracefulShutdown
gracefulShutdown: options.gracefulShutdown !== false
})

this.useCustomFormat = options.format !== undefined
Expand Down Expand Up @@ -90,6 +90,15 @@ class LokiTransport extends Transport {
// Trigger the optional callback
callback()
}

/**
* Send batch to loki when clean up
*/
close () {
this.batcher.sendBatchToLoki()
.then(() => {}) // maybe should emit something here
.catch(() => {}) // maybe should emit something here
}
}

module.exports = LokiTransport

0 comments on commit cedc7da

Please sign in to comment.