From beb94c53e99d25b583f9f88c036b0c8a6f4d9844 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 4 Mar 2017 11:26:49 +0100 Subject: Add hanging indent to log messages. This makes them easier to read. --- src/Text/Pandoc/Class.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index b053e9063..c45249257 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -250,9 +250,18 @@ instance PandocMonad PandocIO where getModificationTime fp = liftIOError IO.getModificationTime fp getCommonState = PandocIO $ lift get putCommonState x = PandocIO $ lift $ put x - logOutput msg = - liftIO $ UTF8.hPutStrLn stderr $ printf "%-7s %s" - (show (messageVerbosity msg)) (showLogMessage msg) + logOutput msg = liftIO $ do + UTF8.hPutStr stderr $ printf "%-7s " (show (messageVerbosity msg)) + hangingIndent 2 $ lines $ showLogMessage msg + +hangingIndent :: Int -> [String] -> IO () +hangingIndent _level [] = return () +hangingIndent level (l:ls) = do + UTF8.hPutStrLn stderr l + mapM_ go ls + where go l' = do UTF8.hPutStr stderr ind + UTF8.hPutStrLn stderr l' + ind = replicate level ' ' -- | Specialized version of parseURIReference that disallows -- single-letter schemes. Reason: these are usually windows absolute -- cgit v1.2.3