Skip to content

Commit

Permalink
Merge pull request #37 from liammclennan/add-stream-flush
Browse files Browse the repository at this point in the history
Add a `flush` method to the stream
  • Loading branch information
liammclennan authored Mar 26, 2024
2 parents b5a90e2 + 384169e commit aac6592
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions example/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
4 changes: 3 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>;
};
}

export = PinoSeq;
5 changes: 5 additions & 0 deletions pinoSeqStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit aac6592

Please sign in to comment.