Skip to content

Commit 6ba157b

Browse files
authored
docs: fix the pino-pretty flush explanation after thread-stream#198 (#2524)
1 parent 6429c14 commit 6ba157b

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎docs/api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ and safer logging at low demand periods.
10971097
10981098
If there is a need to wait for the logs to be flushed, a callback should be used.
10991099
1100-
**Note:** `flush()` does not work when using `pino-pretty`. See
1100+
**Note:** `logger.flush()` does not flush the output of `pino-pretty`. See
11011101
[Flush Limitations with `pino-pretty`](/docs/asynchronous.md) for more details.
11021102
11031103
**Note:** in the browser this method is a no-op and `cb` is never invoked. See

‎docs/asynchronous.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ Asynchronous logging has a couple of important caveats:
3939

4040
### Flush Limitations with `pino-pretty`
4141

42-
The `logger.flush()` method does not work when using `pino-pretty` because:
42+
`logger.flush()` does not flush the output of `pino-pretty` because:
4343

4444
1. **Transport Architecture**: `pino-pretty` runs in a separate worker thread via the transport mechanism.
4545

46-
2. **Buffer Flow**: When you call `logger.flush()`, it flushes the SonicBoom destination in the main thread, but the logs remain queued in the thread-stream worker waiting to be processed by `pino-pretty`.
46+
2. **Cross-Thread Flush**: `logger.flush(cb)` does reach the worker. Since [thread-stream#198](https://github.com/pinojs/thread-stream/pull/198) the worker waits for the shared buffer to be drained, then looks for a flush primitive on the destination the transport returned: `flush`, `flushSync`, or a pending `drain`.
4747

48-
3. **No Cross-Thread Flush**: The flush operation never propagates through to the worker thread where the pretty printer is processing the output.
48+
3. **No Flush Primitive**: The stream `pino-pretty` returns exposes none of those. Its buffered `SonicBoom` is reachable only through the internal `pump`, so the worker has nothing to call and acknowledges the flush right away.
4949

50-
This means that even with `logger.flush()`, your formatted logs may not appear immediately, and the flush will only ensure the main thread buffer is written, not the formatted output.
50+
This means that even with `logger.flush()`, your formatted logs may not appear immediately. The flush only guarantees that the main thread buffer was written and that the worker drained the shared buffer, not that `pino-pretty` has written its formatted output.
5151

5252
See also:
5353

‎docs/pretty.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module like [`pino-pretty`][pp]:
3232
logger.info('hi')
3333
```
3434

35-
**Note:** The `logger.flush()` method does not work when using `pino-pretty`. See
35+
**Note:** `logger.flush()` does not flush the output of `pino-pretty`. See
3636
[Flush Limitations with `pino-pretty`](/docs/asynchronous.md) for more details.
3737

3838
[pp]: https://github.com/pinojs/pino-pretty

0 commit comments

Comments
 (0)