diff --git a/example/example.ts b/example/example.ts index 0568bd7..b3edb57 100644 --- a/example/example.ts +++ b/example/example.ts @@ -13,3 +13,5 @@ logger.info("Hello Seq, from Pino"); const frLogger = logger.child({lang: "fr"}); frLogger.warn("au reviour"); + +stream.flush().then((_) => console.log('flushed')); \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index 09f1f73..193997e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,7 +11,9 @@ declare namespace PinoSeq { onError?: (e: Error) => void; } - function createStream(config: PinoSeq.SeqConfig): Writable; + function createStream(config: PinoSeq.SeqConfig): Writable & { + flush: () => Promise; + }; } export = PinoSeq; diff --git a/pinoSeqStream.js b/pinoSeqStream.js index 14fa097..5b4d84f 100644 --- a/pinoSeqStream.js +++ b/pinoSeqStream.js @@ -98,6 +98,11 @@ class PinoSeqStream extends stream.Writable { } } + flush() { + this.flushBuffer(); + return this._logger.flush(); + } + // Force the underlying logger to flush at the time of the call // and wait for pending writes to complete _final(callback) {