Skip to content

Commit

Permalink
update flush function type (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton authored Oct 5, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 309cdfb commit b48d346
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pino.d.ts
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ export interface LoggerExtras<Options = LoggerOptions> extends EventEmitter {
/**
* Flushes the content of the buffer when using pino.destination({ sync: false }).
*/
flush(): () => void;
flush(): void;
}


4 changes: 2 additions & 2 deletions test/syncfalse.test.js
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ test('sync false with child', async ({ equal, teardown }) => {
})
})

test('flush does nothing with sync true (default)', async () => {
test('flush does nothing with sync true (default)', async ({ equal }) => {
const instance = require('..')()
instance.flush()
equal(instance.flush(), undefined)
})
6 changes: 4 additions & 2 deletions test/transport/syncfalse.test.js
Original file line number Diff line number Diff line change
@@ -10,15 +10,17 @@ const { watchFileCreated, file } = require('../helper')
const { pid } = process
const hostname = os.hostname()

test('thread-stream async flush', async ({ same }) => {
test('thread-stream async flush', async ({ equal, same }) => {
const destination = file()
const transport = pino.transport({
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
options: { destination }
})
const instance = pino(transport)
instance.info('hello')
instance.flush()

equal(instance.flush(), undefined)

await watchFileCreated(destination)
const result = JSON.parse(await readFile(destination))
delete result.time
1 change: 1 addition & 0 deletions test/types/pino.test-d.ts
Original file line number Diff line number Diff line change
@@ -111,6 +111,7 @@ pino({ base: null });
// @ts-expect-error
if ("pino" in log) console.log(`pino version: ${log.pino}`);

expectType<void>(log.flush());
log.child({ a: "property" }).info("hello child!");
log.level = "error";
log.info("nope");

0 comments on commit b48d346

Please sign in to comment.