aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-04 11:26:49 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-04 11:26:49 +0100
commitbeb94c53e99d25b583f9f88c036b0c8a6f4d9844 (patch)
tree55d8201ef51476576fe8d9e7b391a90dc6ac5ff6 /src/Text
parent69b3a369cacdae089d78dfb2e78287176f81a111 (diff)
downloadpandoc-beb94c53e99d25b583f9f88c036b0c8a6f4d9844.tar.gz
Add hanging indent to log messages.
This makes them easier to read.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Class.hs15
1 files changed, 12 insertions, 3 deletions
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