diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-01-22 23:49:05 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:43 +0100 |
commit | bc7e846da61bdcd3ce6ef49e9d3e6bf4a0bd1a5d (patch) | |
tree | bf64321ccb99aa7f694be8dbf28c928f47d9ecf4 /pandoc.hs | |
parent | 4e97efe857aa574d14566ef33e7402840c9ef684 (diff) | |
download | pandoc-bc7e846da61bdcd3ce6ef49e9d3e6bf4a0bd1a5d.tar.gz |
More logging-related changes.
Class:
* Removed getWarnings, withWarningsToStderr
* Added report
* Added logOutput to PandocMonad
* Make logOutput streaming in PandocIO monad
* Properly reverse getLog output
Readers:
* Replaced use of trace with report DEBUG.
TWiki Reader: Put everything inside PandocMonad m.
API changes.
Diffstat (limited to 'pandoc.hs')
-rw-r--r-- | pandoc.hs | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -35,8 +35,7 @@ import Text.Pandoc.Builder (setMeta) import Text.Pandoc.PDF (makePDF) import Text.Pandoc.Walk (walk) import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile, - safeRead, headerShift, err, warn, - openURL ) + safeRead, headerShift, err, openURL ) import Text.Pandoc.MediaBag ( mediaDirectory, extractMediaBag, MediaBag ) import Text.Pandoc.XML ( toEntities ) import Text.Pandoc.SelfContained ( makeSelfContained ) @@ -75,7 +74,7 @@ import System.Posix.Terminal (queryTerminal) import System.Posix.IO (stdOutput) #endif import Control.Monad.Trans -import Text.Pandoc.Class (withMediaBag, PandocIO, getWarnings) +import Text.Pandoc.Class (withMediaBag, PandocIO, getLog, setVerbosity) main :: IO () main = do @@ -354,14 +353,14 @@ convertWithOpts opts args = do let runIO' :: PandocIO a -> IO a runIO' f = do - (res, warnings) <- runIOorExplode $ do + (res, reports) <- runIOorExplode $ do + setVerbosity verbosity x <- f - ws <- getWarnings - return (x, ws) - when (not (null warnings)) $ do - -- TODO make these streaming - when (verbosity >= WARNING) $ mapM_ warn warnings - when failIfWarnings $ + rs <- getLog + return (x, rs) + let isWarning (WARNING, _) = True + isWarning _ = False + when (failIfWarnings && any isWarning reports) $ err 3 "Failing because there were warnings." return res |