summaryrefslogtreecommitdiff
path: root/Messages.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-18 13:01:23 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-18 13:01:23 -0400
commit7a5a254066edca25dc66b7aeb2a87f35ad846604 (patch)
tree3941dbfd4c8bcc15024a5674491809162d4cc2b8 /Messages.hs
parent39887342ce534202036e99f6344d5522f1bceed7 (diff)
Force output to be line-buffered, even when it's not connected to the terminal.
This is particuarly important for commands with --batch output, which was not always being flushed at an appropriate time.
Diffstat (limited to 'Messages.hs')
-rw-r--r--Messages.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Messages.hs b/Messages.hs
index ff26380dd..7b4cff102 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -182,6 +182,11 @@ setupConsole = do
<*> pure preciseLogFormatter
updateGlobalLogger rootLoggerName (setLevel NOTICE . setHandlers [s])
setConsoleEncoding
+ {- Force output to be line buffered. This is normally the case when
+ - it's connected to a terminal, but may not be when redirected to
+ - a file or a pipe. -}
+ hSetBuffering stdout LineBuffering
+ hSetBuffering stderr LineBuffering
{- Log formatter with precision into fractions of a second. -}
preciseLogFormatter :: LogFormatter a