git.iko.soy/typeable/pandoc
on master help sign in
Added --log option to save log messages in JSON format to a file.
a6c649cJohn MacFarlane
MANUAL.txt+6
@@ -356,6 +356,12 @@ General options
356
356
357: Exit with error status if there are any warnings.
357: Exit with error status if there are any warnings.
358
358
359+`--log=`*FILE*
360+
361+: Write log messages in machine-readable JSON format to
362+ *FILE*. All messages above DEBUG level will be written,
363+ regardless of verbosity settings (`--verbose`, `--quiet`).
364+
359`--list-input-formats`
365`--list-input-formats`
360
366
361: List supported input formats, one per line.
367: List supported input formats, one per line.
pandoc.cabal+2−17
@@ -275,6 +275,7 @@ Library
275 extensible-exceptions >= 0.1 && < 0.2,
275 extensible-exceptions >= 0.1 && < 0.2,
276 pandoc-types >= 1.17 && < 1.18,
276 pandoc-types >= 1.17 && < 1.18,
277 aeson >= 0.7 && < 1.2,
277 aeson >= 0.7 && < 1.2,
278+ aeson-pretty >= 0.8 && < 0.9,
278 tagsoup >= 0.13.7 && < 0.15,
279 tagsoup >= 0.13.7 && < 0.15,
279 base64-bytestring >= 0.1 && < 1.1,
280 base64-bytestring >= 0.1 && < 1.1,
280 zlib >= 0.5 && < 0.7,
281 zlib >= 0.5 && < 0.7,
@@ -435,23 +436,7 @@ Library
435
436
436Executable pandoc
437Executable pandoc
437 Build-Depends: pandoc,
438 Build-Depends: pandoc,
438− pandoc-types >= 1.17 && < 1.18,
439− base >= 4.2 && <5,
439+ base >= 4.2 && < 5
440− directory >= 1.2 && < 1.4,
441− filepath >= 1.1 && < 1.5,
442− text >= 0.11 && < 1.3,
443− bytestring >= 0.9 && < 0.11,
444− extensible-exceptions >= 0.1 && < 0.2,
445− skylighting >= 0.1.1.3 && < 0.2,
446− aeson >= 0.7.0.5 && < 1.2,
447− yaml >= 0.8.8.2 && < 0.9,
448− containers >= 0.1 && < 0.6,
449− HTTP >= 4000.0.5 && < 4000.4,
450− mtl >= 2.2 && < 2.3
451− if flag(network-uri)
452− Build-Depends: network-uri >= 2.6 && < 2.7, network >= 2.6
453− else
454− Build-Depends: network >= 2 && < 2.6
455 Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
440 Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
456 Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m
441 Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m
457
442
src/Text/Pandoc/App.hs+12
@@ -71,6 +71,7 @@ import qualified Data.ByteString.Lazy as B
71import qualified Data.ByteString as BS
71import qualified Data.ByteString as BS
72import qualified Data.Map as M
72import qualified Data.Map as M
73import Data.Aeson (eitherDecode', encode)
73import Data.Aeson (eitherDecode', encode)
74+import Data.Aeson.Encode.Pretty (encodePretty)
74import Data.Yaml (decode)
75import Data.Yaml (decode)
75import qualified Data.Yaml as Yaml
76import qualified Data.Yaml as Yaml
76import qualified Data.Text as T
77import qualified Data.Text as T
@@ -348,6 +349,9 @@ convertWithOpts opts = do
348 x <- f
349 x <- f
349 rs <- getLog
350 rs <- getLog
350 return (x, rs)
351 return (x, rs)
352+ case optLogFile opts of
353+ Nothing -> return ()
354+ Just logfile -> B.writeFile logfile (encodePretty reports)
351 let isWarning msg = messageVerbosity msg == WARNING
355 let isWarning msg = messageVerbosity msg == WARNING
352 when (optFailIfWarnings opts && any isWarning reports) $
356 when (optFailIfWarnings opts && any isWarning reports) $
353 err 3 "Failing because there were warnings."
357 err 3 "Failing because there were warnings."
@@ -487,6 +491,7 @@ data Opt = Opt
487 , optDumpArgs :: Bool -- ^ Output command-line arguments
491 , optDumpArgs :: Bool -- ^ Output command-line arguments
488 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
492 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
489 , optVerbosity :: Verbosity -- ^ Verbosity of diagnostic output
493 , optVerbosity :: Verbosity -- ^ Verbosity of diagnostic output
494+ , optLogFile :: Maybe FilePath -- ^ File to write JSON log output
490 , optFailIfWarnings :: Bool -- ^ Fail on warnings
495 , optFailIfWarnings :: Bool -- ^ Fail on warnings
491 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
496 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
492 , optReferenceLocation :: ReferenceLocation -- ^ location for footnotes and link references in markdown output
497 , optReferenceLocation :: ReferenceLocation -- ^ location for footnotes and link references in markdown output
@@ -552,6 +557,7 @@ defaultOpts = Opt
552 , optDumpArgs = False
557 , optDumpArgs = False
553 , optIgnoreArgs = False
558 , optIgnoreArgs = False
554 , optVerbosity = WARNING
559 , optVerbosity = WARNING
560+ , optLogFile = Nothing
555 , optFailIfWarnings = False
561 , optFailIfWarnings = False
556 , optReferenceLinks = False
562 , optReferenceLinks = False
557 , optReferenceLocation = EndOfDocument
563 , optReferenceLocation = EndOfDocument
@@ -1289,6 +1295,12 @@ options =
1289 (\opt -> return opt { optFailIfWarnings = True }))
1295 (\opt -> return opt { optFailIfWarnings = True }))
1290 "" -- "Exit with error status if there were warnings."
1296 "" -- "Exit with error status if there were warnings."
1291
1297
1298+ , Option "" ["log"]
1299+ (ReqArg
1300+ (\arg opt -> return opt{ optLogFile = Just arg })
1301+ "FILE")
1302+ "" -- "Log messages in JSON format to this file."
1303+
1292 , Option "" ["bash-completion"]
1304 , Option "" ["bash-completion"]
1293 (NoArg
1305 (NoArg
1294 (\_ -> do
1306 (\_ -> do