You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* [#176] Add an action to flush a handle
Problem: during logging one often wants data to reach destination
immediately, but logging actions provided out of the box do not
flush handles they log to.
Solution: we add a new action to `co-log-core`. This action does
not _write_ anything, but flushes the handler. We call it
`logFlush` for consistency with other `log*` actions.
It can be used as `logPrintStderr <> logFlush stderr`.
* fixup! [#191] Export showTime (#192)
* [#176] Automatically flush file handles
Problem: if we use builtin logging actions that log to files,
you will often notice that your messages appear in files with delay
due to buffering. File handles are usually block-buffered and do not
flush on newlines.
We find that behavior confusing to end users and think that it's
better to flush file handles on each log action by default.
Note that the same problem may occur with other handles (e. g. stderr)
as well, but it's less likely because they normally have line
buffering (but it's not guaranteed and is not always the case).
Solution: first of all we checked performance overhead of additional
`hFlush` call. For vanilla `putStrLn` it varies from "more than 4x"
for short messages to negligible for long messages. On average we
roughly assess it as 2x (that really depends on your use case).
Based on that we make the following trade-off:
1. Actions that write to files now also automatically flush output
buffers using `logFlush`. That's more expensive, but without flushing
behavior is quite confusing for the library users.
2. Actions that write to an arbitrary `Handle` or standard handles
do not flush by default to avoid overhead. Usually flushing will
happen automatically because of line bufferring.
* [#176] Clarify lack of flushing in default actions
* fixup! [#176] Automatically flush file handles
0 commit comments