Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update flush function type #1824

Merged
merged 5 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pino.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
rluvaton marked this conversation as resolved.
Show resolved Hide resolved
rluvaton marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down
4 changes: 2 additions & 2 deletions test/syncfalse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/types/pino.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down