diff options
author | 2015-11-04 13:45:34 -0400 | |
---|---|---|
committer | 2015-11-04 13:45:34 -0400 | |
commit | 1933f8a5599f33b95811710ad10e1ed17703699d (patch) | |
tree | acf454abe167051a7ff77a752deb6c5b9f45a758 /Messages/Internal.hs | |
parent | c3a372f8f500f6b88d467af42df6332836d8dd31 (diff) |
concurrent-output, first pass
Output without -Jn should be unchanged from before. With -Jn,
concurrent-output is used for messages, but regions are not used yet, so
it's a mess.
Diffstat (limited to 'Messages/Internal.hs')
-rw-r--r-- | Messages/Internal.hs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/Messages/Internal.hs b/Messages/Internal.hs index 2495f4fd3..1501c072a 100644 --- a/Messages/Internal.hs +++ b/Messages/Internal.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Messages.Internal where import Common @@ -12,14 +14,38 @@ import Types import Types.Messages import qualified Annex -handleMessage :: IO () -> IO () -> Annex () -handleMessage json normal = withOutputType go +#ifdef WITH_CONCURRENTOUTPUT +import System.Console.Concurrent +#endif + +outputMessage :: IO () -> String -> Annex () +outputMessage json s = withOutputType go where - go NormalOutput = liftIO normal + go NormalOutput = liftIO $ + flushed $ putStr s go QuietOutput = q - go (ParallelOutput _) = q + go (ConcurrentOutput _) = liftIO $ +#ifdef WITH_CONCURRENTOUTPUT + outputConcurrent s +#else + q +#endif go JSONOutput = liftIO $ flushed json +outputError :: String -> Annex () +outputError s = withOutputType go + where + go (ConcurrentOutput _) = liftIO $ +#ifdef WITH_CONCURRENTOUTPUT + errorConcurrent s +#else + q +#endif + go _ = liftIO $ do + hFlush stdout + hPutStr stderr s + hFlush stderr + q :: Monad m => m () q = noop |