{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE LambdaCase         #-}
{-# LANGUAGE OverloadedStrings  #-}
{- |
   Module      : Text.Pandoc.Logging
   Copyright   : Copyright (C) 2006-2021 John MacFarlane
   License     : GNU GPL, version 2 or above

   Maintainer  : John MacFarlane <jgm@berkeley.edu>
   Stability   : alpha
   Portability : portable

This module provides data types and functions for warnings
and info messages.

-}
module Text.Pandoc.Logging (
    Verbosity(..)
  , LogMessage(..)
  , encodeLogMessages
  , showLogMessage
  , messageVerbosity
  ) where

import Control.Monad (mzero)
import Data.YAML (withStr, FromYAML(..))
import Data.Aeson
import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',
                                 keyOrder)
import qualified Data.ByteString.Lazy as BL
import Data.Data (Data, toConstr)
import qualified Data.Text as Text
import Data.Text (Text)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Text.Pandoc.Definition
import Text.Parsec.Pos
import Text.Pandoc.Shared (tshow)

-- | Verbosity level.
data Verbosity = ERROR | WARNING | INFO
     deriving (Int -> Verbosity -> ShowS
[Verbosity] -> ShowS
Verbosity -> String
(Int -> Verbosity -> ShowS)
-> (Verbosity -> String)
-> ([Verbosity] -> ShowS)
-> Show Verbosity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Verbosity] -> ShowS
$cshowList :: [Verbosity] -> ShowS
show :: Verbosity -> String
$cshow :: Verbosity -> String
showsPrec :: Int -> Verbosity -> ShowS
$cshowsPrec :: Int -> Verbosity -> ShowS
Show, ReadPrec [Verbosity]
ReadPrec Verbosity
Int -> ReadS Verbosity
ReadS [Verbosity]
(Int -> ReadS Verbosity)
-> ReadS [Verbosity]
-> ReadPrec Verbosity
-> ReadPrec [Verbosity]
-> Read Verbosity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Verbosity]
$creadListPrec :: ReadPrec [Verbosity]
readPrec :: ReadPrec Verbosity
$creadPrec :: ReadPrec Verbosity
readList :: ReadS [Verbosity]
$creadList :: ReadS [Verbosity]
readsPrec :: Int -> ReadS Verbosity
$creadsPrec :: Int -> ReadS Verbosity
Read, Verbosity -> Verbosity -> Bool
(Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool) -> Eq Verbosity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Verbosity -> Verbosity -> Bool
$c/= :: Verbosity -> Verbosity -> Bool
== :: Verbosity -> Verbosity -> Bool
$c== :: Verbosity -> Verbosity -> Bool
Eq, Typeable Verbosity
DataType
Constr
Typeable Verbosity
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Verbosity -> c Verbosity)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Verbosity)
-> (Verbosity -> Constr)
-> (Verbosity -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Verbosity))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Verbosity))
-> ((forall b. Data b => b -> b) -> Verbosity -> Verbosity)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Verbosity -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Verbosity -> r)
-> (forall u. (forall d. Data d => d -> u) -> Verbosity -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Verbosity -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Verbosity -> m Verbosity)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Verbosity -> m Verbosity)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Verbosity -> m Verbosity)
-> Data Verbosity
Verbosity -> DataType
Verbosity -> Constr
(forall b. Data b => b -> b) -> Verbosity -> Verbosity
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Verbosity -> c Verbosity
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Verbosity
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Verbosity -> u
forall u. (forall d. Data d => d -> u) -> Verbosity -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Verbosity -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Verbosity -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Verbosity
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Verbosity -> c Verbosity
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Verbosity)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Verbosity)
$cINFO :: Constr
$cWARNING :: Constr
$cERROR :: Constr
$tVerbosity :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
gmapMp :: (forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
gmapM :: (forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Verbosity -> m Verbosity
gmapQi :: Int -> (forall d. Data d => d -> u) -> Verbosity -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Verbosity -> u
gmapQ :: (forall d. Data d => d -> u) -> Verbosity -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Verbosity -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Verbosity -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Verbosity -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Verbosity -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Verbosity -> r
gmapT :: (forall b. Data b => b -> b) -> Verbosity -> Verbosity
$cgmapT :: (forall b. Data b => b -> b) -> Verbosity -> Verbosity
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Verbosity)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Verbosity)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Verbosity)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Verbosity)
dataTypeOf :: Verbosity -> DataType
$cdataTypeOf :: Verbosity -> DataType
toConstr :: Verbosity -> Constr
$ctoConstr :: Verbosity -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Verbosity
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Verbosity
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Verbosity -> c Verbosity
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Verbosity -> c Verbosity
$cp1Data :: Typeable Verbosity
Data, Int -> Verbosity
Verbosity -> Int
Verbosity -> [Verbosity]
Verbosity -> Verbosity
Verbosity -> Verbosity -> [Verbosity]
Verbosity -> Verbosity -> Verbosity -> [Verbosity]
(Verbosity -> Verbosity)
-> (Verbosity -> Verbosity)
-> (Int -> Verbosity)
-> (Verbosity -> Int)
-> (Verbosity -> [Verbosity])
-> (Verbosity -> Verbosity -> [Verbosity])
-> (Verbosity -> Verbosity -> [Verbosity])
-> (Verbosity -> Verbosity -> Verbosity -> [Verbosity])
-> Enum Verbosity
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Verbosity -> Verbosity -> Verbosity -> [Verbosity]
$cenumFromThenTo :: Verbosity -> Verbosity -> Verbosity -> [Verbosity]
enumFromTo :: Verbosity -> Verbosity -> [Verbosity]
$cenumFromTo :: Verbosity -> Verbosity -> [Verbosity]
enumFromThen :: Verbosity -> Verbosity -> [Verbosity]
$cenumFromThen :: Verbosity -> Verbosity -> [Verbosity]
enumFrom :: Verbosity -> [Verbosity]
$cenumFrom :: Verbosity -> [Verbosity]
fromEnum :: Verbosity -> Int
$cfromEnum :: Verbosity -> Int
toEnum :: Int -> Verbosity
$ctoEnum :: Int -> Verbosity
pred :: Verbosity -> Verbosity
$cpred :: Verbosity -> Verbosity
succ :: Verbosity -> Verbosity
$csucc :: Verbosity -> Verbosity
Enum, Eq Verbosity
Eq Verbosity
-> (Verbosity -> Verbosity -> Ordering)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Bool)
-> (Verbosity -> Verbosity -> Verbosity)
-> (Verbosity -> Verbosity -> Verbosity)
-> Ord Verbosity
Verbosity -> Verbosity -> Bool
Verbosity -> Verbosity -> Ordering
Verbosity -> Verbosity -> Verbosity
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Verbosity -> Verbosity -> Verbosity
$cmin :: Verbosity -> Verbosity -> Verbosity
max :: Verbosity -> Verbosity -> Verbosity
$cmax :: Verbosity -> Verbosity -> Verbosity
>= :: Verbosity -> Verbosity -> Bool
$c>= :: Verbosity -> Verbosity -> Bool
> :: Verbosity -> Verbosity -> Bool
$c> :: Verbosity -> Verbosity -> Bool
<= :: Verbosity -> Verbosity -> Bool
$c<= :: Verbosity -> Verbosity -> Bool
< :: Verbosity -> Verbosity -> Bool
$c< :: Verbosity -> Verbosity -> Bool
compare :: Verbosity -> Verbosity -> Ordering
$ccompare :: Verbosity -> Verbosity -> Ordering
$cp1Ord :: Eq Verbosity
Ord, Verbosity
Verbosity -> Verbosity -> Bounded Verbosity
forall a. a -> a -> Bounded a
maxBound :: Verbosity
$cmaxBound :: Verbosity
minBound :: Verbosity
$cminBound :: Verbosity
Bounded, Typeable, (forall x. Verbosity -> Rep Verbosity x)
-> (forall x. Rep Verbosity x -> Verbosity) -> Generic Verbosity
forall x. Rep Verbosity x -> Verbosity
forall x. Verbosity -> Rep Verbosity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Verbosity x -> Verbosity
$cfrom :: forall x. Verbosity -> Rep Verbosity x
Generic)

instance ToJSON Verbosity where
  toJSON :: Verbosity -> Value
toJSON Verbosity
x = String -> Value
forall a. ToJSON a => a -> Value
toJSON (Verbosity -> String
forall a. Show a => a -> String
show Verbosity
x)
instance FromJSON Verbosity where
  parseJSON :: Value -> Parser Verbosity
parseJSON (String Text
t) =
    case Text
t of
         Text
"ERROR"   -> Verbosity -> Parser Verbosity
forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
ERROR
         Text
"WARNING" -> Verbosity -> Parser Verbosity
forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
WARNING
         Text
"INFO"    -> Verbosity -> Parser Verbosity
forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
INFO
         Text
_         -> Parser Verbosity
forall (m :: * -> *) a. MonadPlus m => m a
mzero
  parseJSON Value
_      =  Parser Verbosity
forall (m :: * -> *) a. MonadPlus m => m a
mzero

instance FromYAML Verbosity where
  parseYAML :: Node Pos -> Parser Verbosity
parseYAML = String
-> (Text -> Parser Verbosity) -> Node Pos -> Parser Verbosity
forall a. String -> (Text -> Parser a) -> Node Pos -> Parser a
withStr String
"Verbosity" ((Text -> Parser Verbosity) -> Node Pos -> Parser Verbosity)
-> (Text -> Parser Verbosity) -> Node Pos -> Parser Verbosity
forall a b. (a -> b) -> a -> b
$ \case
         Text
"ERROR"   -> Verbosity -> Parser Verbosity
forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
ERROR
         Text
"WARNING" -> Verbosity -> Parser Verbosity
forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
WARNING
         Text
"INFO"    -> Verbosity -> Parser Verbosity
forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
INFO
         Text
_         -> Parser Verbosity
forall (m :: * -> *) a. MonadPlus m => m a
mzero

data LogMessage =
    SkippedContent Text SourcePos
  | IgnoredElement Text
  | DuplicateLinkReference Text SourcePos
  | DuplicateNoteReference Text SourcePos
  | NoteDefinedButNotUsed Text SourcePos
  | DuplicateIdentifier Text SourcePos
  | ReferenceNotFound Text SourcePos
  | CircularReference Text SourcePos
  | UndefinedToggle Text SourcePos
  | ParsingUnescaped Text SourcePos
  | CouldNotLoadIncludeFile Text SourcePos
  | MacroAlreadyDefined Text SourcePos
  | InlineNotRendered Inline
  | BlockNotRendered Block
  | DocxParserWarning Text
  | PowerpointTemplateWarning Text
  | IgnoredIOError Text
  | CouldNotFetchResource Text Text
  | CouldNotDetermineImageSize Text Text
  | CouldNotConvertImage Text Text
  | CouldNotDetermineMimeType Text
  | CouldNotConvertTeXMath Text Text
  | CouldNotParseCSS Text
  | Fetching Text
  | Extracting Text
  | LoadedResource FilePath FilePath
  | NoTitleElement Text
  | NoLangSpecified
  | InvalidLang Text
  | CouldNotHighlight Text
  | MissingCharacter Text
  | Deprecated Text Text
  | NoTranslation Text
  | CouldNotLoadTranslations Text Text
  | UnusualConversion Text
  | UnexpectedXmlElement Text Text
  | UnknownOrgExportOption Text
  | CouldNotDeduceFormat [Text] Text
  | RunningFilter FilePath
  | FilterCompleted FilePath Integer
  | CiteprocWarning Text
  | ATXHeadingInLHS Int Text
  | EnvironmentVariableUndefined Text
  | DuplicateAttribute Text Text
  | NotUTF8Encoded FilePath
  deriving (Int -> LogMessage -> ShowS
[LogMessage] -> ShowS
LogMessage -> String
(Int -> LogMessage -> ShowS)
-> (LogMessage -> String)
-> ([LogMessage] -> ShowS)
-> Show LogMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogMessage] -> ShowS
$cshowList :: [LogMessage] -> ShowS
show :: LogMessage -> String
$cshow :: LogMessage -> String
showsPrec :: Int -> LogMessage -> ShowS
$cshowsPrec :: Int -> LogMessage -> ShowS
Show, LogMessage -> LogMessage -> Bool
(LogMessage -> LogMessage -> Bool)
-> (LogMessage -> LogMessage -> Bool) -> Eq LogMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogMessage -> LogMessage -> Bool
$c/= :: LogMessage -> LogMessage -> Bool
== :: LogMessage -> LogMessage -> Bool
$c== :: LogMessage -> LogMessage -> Bool
Eq, Typeable LogMessage
DataType
Constr
Typeable LogMessage
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> LogMessage -> c LogMessage)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c LogMessage)
-> (LogMessage -> Constr)
-> (LogMessage -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c LogMessage))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c LogMessage))
-> ((forall b. Data b => b -> b) -> LogMessage -> LogMessage)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> LogMessage -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> LogMessage -> r)
-> (forall u. (forall d. Data d => d -> u) -> LogMessage -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> LogMessage -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> LogMessage -> m LogMessage)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> LogMessage -> m LogMessage)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> LogMessage -> m LogMessage)
-> Data LogMessage
LogMessage -> DataType
LogMessage -> Constr
(forall b. Data b => b -> b) -> LogMessage -> LogMessage
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LogMessage -> c LogMessage
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LogMessage
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> LogMessage -> u
forall u. (forall d. Data d => d -> u) -> LogMessage -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LogMessage -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LogMessage -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LogMessage
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LogMessage -> c LogMessage
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LogMessage)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LogMessage)
$cNotUTF8Encoded :: Constr
$cDuplicateAttribute :: Constr
$cEnvironmentVariableUndefined :: Constr
$cATXHeadingInLHS :: Constr
$cCiteprocWarning :: Constr
$cFilterCompleted :: Constr
$cRunningFilter :: Constr
$cCouldNotDeduceFormat :: Constr
$cUnknownOrgExportOption :: Constr
$cUnexpectedXmlElement :: Constr
$cUnusualConversion :: Constr
$cCouldNotLoadTranslations :: Constr
$cNoTranslation :: Constr
$cDeprecated :: Constr
$cMissingCharacter :: Constr
$cCouldNotHighlight :: Constr
$cInvalidLang :: Constr
$cNoLangSpecified :: Constr
$cNoTitleElement :: Constr
$cLoadedResource :: Constr
$cExtracting :: Constr
$cFetching :: Constr
$cCouldNotParseCSS :: Constr
$cCouldNotConvertTeXMath :: Constr
$cCouldNotDetermineMimeType :: Constr
$cCouldNotConvertImage :: Constr
$cCouldNotDetermineImageSize :: Constr
$cCouldNotFetchResource :: Constr
$cIgnoredIOError :: Constr
$cPowerpointTemplateWarning :: Constr
$cDocxParserWarning :: Constr
$cBlockNotRendered :: Constr
$cInlineNotRendered :: Constr
$cMacroAlreadyDefined :: Constr
$cCouldNotLoadIncludeFile :: Constr
$cParsingUnescaped :: Constr
$cUndefinedToggle :: Constr
$cCircularReference :: Constr
$cReferenceNotFound :: Constr
$cDuplicateIdentifier :: Constr
$cNoteDefinedButNotUsed :: Constr
$cDuplicateNoteReference :: Constr
$cDuplicateLinkReference :: Constr
$cIgnoredElement :: Constr
$cSkippedContent :: Constr
$tLogMessage :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
gmapMp :: (forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
gmapM :: (forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> LogMessage -> m LogMessage
gmapQi :: Int -> (forall d. Data d => d -> u) -> LogMessage -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> LogMessage -> u
gmapQ :: (forall d. Data d => d -> u) -> LogMessage -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> LogMessage -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LogMessage -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LogMessage -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LogMessage -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LogMessage -> r
gmapT :: (forall b. Data b => b -> b) -> LogMessage -> LogMessage
$cgmapT :: (forall b. Data b => b -> b) -> LogMessage -> LogMessage
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LogMessage)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LogMessage)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c LogMessage)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LogMessage)
dataTypeOf :: LogMessage -> DataType
$cdataTypeOf :: LogMessage -> DataType
toConstr :: LogMessage -> Constr
$ctoConstr :: LogMessage -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LogMessage
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LogMessage
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LogMessage -> c LogMessage
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LogMessage -> c LogMessage
$cp1Data :: Typeable LogMessage
Data, Eq LogMessage
Eq LogMessage
-> (LogMessage -> LogMessage -> Ordering)
-> (LogMessage -> LogMessage -> Bool)
-> (LogMessage -> LogMessage -> Bool)
-> (LogMessage -> LogMessage -> Bool)
-> (LogMessage -> LogMessage -> Bool)
-> (LogMessage -> LogMessage -> LogMessage)
-> (LogMessage -> LogMessage -> LogMessage)
-> Ord LogMessage
LogMessage -> LogMessage -> Bool
LogMessage -> LogMessage -> Ordering
LogMessage -> LogMessage -> LogMessage
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LogMessage -> LogMessage -> LogMessage
$cmin :: LogMessage -> LogMessage -> LogMessage
max :: LogMessage -> LogMessage -> LogMessage
$cmax :: LogMessage -> LogMessage -> LogMessage
>= :: LogMessage -> LogMessage -> Bool
$c>= :: LogMessage -> LogMessage -> Bool
> :: LogMessage -> LogMessage -> Bool
$c> :: LogMessage -> LogMessage -> Bool
<= :: LogMessage -> LogMessage -> Bool
$c<= :: LogMessage -> LogMessage -> Bool
< :: LogMessage -> LogMessage -> Bool
$c< :: LogMessage -> LogMessage -> Bool
compare :: LogMessage -> LogMessage -> Ordering
$ccompare :: LogMessage -> LogMessage -> Ordering
$cp1Ord :: Eq LogMessage
Ord, Typeable, (forall x. LogMessage -> Rep LogMessage x)
-> (forall x. Rep LogMessage x -> LogMessage) -> Generic LogMessage
forall x. Rep LogMessage x -> LogMessage
forall x. LogMessage -> Rep LogMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogMessage x -> LogMessage
$cfrom :: forall x. LogMessage -> Rep LogMessage x
Generic)

instance ToJSON LogMessage where
  toJSON :: LogMessage -> Value
toJSON LogMessage
x = [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
    Key
"verbosity" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Verbosity -> Value
forall a. ToJSON a => a -> Value
toJSON (LogMessage -> Verbosity
messageVerbosity LogMessage
x) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
:
    Key
"type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String -> Value
forall a. ToJSON a => a -> Value
toJSON (Constr -> String
forall a. Show a => a -> String
show (Constr -> String) -> Constr -> String
forall a b. (a -> b) -> a -> b
$ LogMessage -> Constr
forall a. Data a => a -> Constr
toConstr LogMessage
x) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
:
    case LogMessage
x of
      SkippedContent Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> Int
sourceLine SourcePos
pos,
            Key
"column" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> Int
sourceColumn SourcePos
pos]
      IgnoredElement Text
s ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      DuplicateLinkReference Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      NoteDefinedButNotUsed Text
s SourcePos
pos ->
           [Key
"key" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      DuplicateNoteReference Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      DuplicateIdentifier Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      ReferenceNotFound Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      CircularReference Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      UndefinedToggle Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      ParsingUnescaped Text
s SourcePos
pos ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      CouldNotLoadIncludeFile Text
fp SourcePos
pos ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      MacroAlreadyDefined Text
name SourcePos
pos ->
           [Key
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
name,
            Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> String
sourceName SourcePos
pos,
            Key
"line" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      InlineNotRendered Inline
il ->
           [Key
"contents" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Inline -> Value
forall a. ToJSON a => a -> Value
toJSON Inline
il]
      BlockNotRendered Block
bl ->
           [Key
"contents" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Block -> Value
forall a. ToJSON a => a -> Value
toJSON Block
bl]
      DocxParserWarning Text
s ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      PowerpointTemplateWarning Text
s ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      IgnoredIOError Text
s ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotFetchResource Text
fp Text
s ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotDetermineImageSize Text
fp Text
s ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotConvertImage Text
fp Text
s ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotDetermineMimeType Text
fp ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp]
      CouldNotConvertTeXMath Text
s Text
msg ->
           [Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      CouldNotParseCSS Text
msg ->
           [Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      Fetching Text
fp ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp]
      Extracting Text
fp ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp]
      LoadedResource String
orig String
found ->
           [Key
"for"  Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
orig
           ,Key
"from" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
found]
      NoTitleElement Text
fallback ->
           [Key
"fallback" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fallback]
      LogMessage
NoLangSpecified -> []
      InvalidLang Text
s ->
           [Key
"lang" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotHighlight Text
msg ->
           [Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      MissingCharacter Text
msg ->
           [Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      Deprecated Text
thing Text
msg ->
           [Key
"thing" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
thing,
            Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      NoTranslation Text
term ->
           [Key
"term" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
term]
      CouldNotLoadTranslations Text
lang Text
msg ->
           [Key
"lang" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
lang,
            Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      UnusualConversion Text
msg ->
           [Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      UnexpectedXmlElement Text
element Text
parent ->
           [Key
"element" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
element,
            Key
"parent" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
parent]
      UnknownOrgExportOption Text
option ->
           [Key
"option" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
option]
      CouldNotDeduceFormat [Text]
exts Text
format ->
           [Key
"extensions" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
exts
           ,Key
"format" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
format]
      RunningFilter String
fp ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String -> Text
Text.pack String
fp ]
      FilterCompleted String
fp Integer
ms ->
           [Key
"path" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String -> Text
Text.pack String
fp
           ,Key
"milliseconds" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String -> Text
Text.pack (Integer -> String
forall a. Show a => a -> String
show Integer
ms) ]
      CiteprocWarning Text
msg ->
           [Key
"message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      ATXHeadingInLHS Int
lvl Text
contents ->
           [Key
"level" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
lvl
           ,Key
"contents" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
contents]
      EnvironmentVariableUndefined Text
var ->
           [Key
"variable" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
var ]
      DuplicateAttribute Text
attr Text
val ->
           [Key
"attribute" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
attr
           ,Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
val]
      NotUTF8Encoded String
src ->
           [Key
"source" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
src]

showPos :: SourcePos -> Text
showPos :: SourcePos -> Text
showPos SourcePos
pos = String -> Text
Text.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ String
sn String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"line " String -> ShowS
forall a. [a] -> [a] -> [a]
++
     Int -> String
forall a. Show a => a -> String
show (SourcePos -> Int
sourceLine SourcePos
pos) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" column " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (SourcePos -> Int
sourceColumn SourcePos
pos)
  where
    sn' :: String
sn' = SourcePos -> String
sourceName SourcePos
pos
    sn :: String
sn = if String
sn' String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"source" Bool -> Bool -> Bool
|| String
sn' String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"" Bool -> Bool -> Bool
|| String
sn' String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"-"
            then String
""
            else String
sn' String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" "

encodeLogMessages :: [LogMessage] -> BL.ByteString
encodeLogMessages :: [LogMessage] -> ByteString
encodeLogMessages [LogMessage]
ms =
  Config -> [LogMessage] -> ByteString
forall a. ToJSON a => Config -> a -> ByteString
encodePretty' Config
defConfig{ confCompare :: Text -> Text -> Ordering
confCompare =
      [Text] -> Text -> Text -> Ordering
keyOrder [ Text
"type", Text
"verbosity", Text
"contents", Text
"message", Text
"path",
                 Text
"source", Text
"line", Text
"column" ] } [LogMessage]
ms

showLogMessage :: LogMessage -> Text
showLogMessage :: LogMessage -> Text
showLogMessage LogMessage
msg =
  case LogMessage
msg of
       SkippedContent Text
s SourcePos
pos ->
         Text
"Skipped '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       IgnoredElement Text
s ->
         Text
"Ignored element " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       DuplicateLinkReference Text
s SourcePos
pos ->
         Text
"Duplicate link reference '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       DuplicateNoteReference Text
s SourcePos
pos ->
         Text
"Duplicate note reference '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       NoteDefinedButNotUsed Text
s SourcePos
pos ->
         Text
"Note with key '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' defined at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           Text
" but not used."
       DuplicateIdentifier Text
s SourcePos
pos ->
         Text
"Duplicate identifier '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       ReferenceNotFound Text
s SourcePos
pos ->
         Text
"Reference not found for '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       CircularReference Text
s SourcePos
pos ->
         Text
"Circular reference '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       UndefinedToggle Text
s SourcePos
pos ->
         Text
"Undefined toggle '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       ParsingUnescaped Text
s SourcePos
pos ->
         Text
"Parsing unescaped '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       CouldNotLoadIncludeFile Text
fp SourcePos
pos ->
         Text
"Could not load include file " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       MacroAlreadyDefined Text
name SourcePos
pos ->
         Text
"Macro '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' already defined, ignoring at " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       InlineNotRendered Inline
il ->
         Text
"Not rendering " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (Inline -> String
forall a. Show a => a -> String
show Inline
il)
       BlockNotRendered Block
bl ->
         Text
"Not rendering " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (Block -> String
forall a. Show a => a -> String
show Block
bl)
       DocxParserWarning Text
s ->
         Text
"Docx parser warning: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       PowerpointTemplateWarning Text
s ->
         Text
"Powerpoint template warning: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       IgnoredIOError Text
s ->
         Text
"IO Error (ignored): " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotFetchResource Text
fp Text
s ->
         Text
"Could not fetch resource " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
s then Text
"" else Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotDetermineImageSize Text
fp Text
s ->
         Text
"Could not determine image size for " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
s then Text
"" else Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotConvertImage Text
fp Text
s ->
         Text
"Could not convert image " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
s then Text
"" else Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotDetermineMimeType Text
fp ->
         Text
"Could not determine mime type for " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp
       CouldNotConvertTeXMath Text
s Text
m ->
         Text
"Could not convert TeX math " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
", rendering as TeX" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
m then Text
"" else Text
":\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       CouldNotParseCSS Text
m ->
         Text
"Could not parse CSS" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> if Text -> Bool
Text.null Text
m then Text
"" else Text
":\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       Fetching Text
fp ->
         Text
"Fetching " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"..."
       Extracting Text
fp ->
         Text
"Extracting " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"..."
       LoadedResource String
orig String
found ->
         Text
"Loaded " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack String
orig Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" from " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack String
found
       NoTitleElement Text
fallback ->
         Text
"This document format requires a nonempty <title> element.\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"Defaulting to '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fallback Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' as the title.\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"To specify a title, use 'title' in metadata or " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"--metadata title=\"...\"."
       LogMessage
NoLangSpecified ->
         Text
"No value for 'lang' was specified in the metadata.\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"It is recommended that lang be specified for this format."
       InvalidLang Text
s ->
         Text
"Invalid 'lang' value '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"'.\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"Use an IETF language tag like 'en-US'."
       CouldNotHighlight Text
m ->
         Text
"Could not highlight code block:\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       MissingCharacter Text
m ->
         Text
"Missing character: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       Deprecated Text
t Text
m ->
         Text
"Deprecated: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         if Text -> Bool
Text.null Text
m
            then Text
""
            else Text
". " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       NoTranslation Text
t ->
         Text
"The term " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" has no translation defined."
       CouldNotLoadTranslations Text
lang Text
m ->
         Text
"Could not load translations for " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
lang Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
m then Text
"" else Text
"\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       UnusualConversion Text
m ->
         Text
"Unusual conversion: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
m
       UnexpectedXmlElement Text
element Text
parent ->
         Text
"Unexpected XML element " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
element Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" in " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
parent
       UnknownOrgExportOption Text
option ->
         Text
"Ignoring unknown Org export option: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
option
       CouldNotDeduceFormat [Text]
exts Text
format ->
         Text
"Could not deduce format from file extension " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text -> [Text] -> Text
Text.intercalate Text
" or " [Text]
exts Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"Defaulting to " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
format
       RunningFilter String
fp -> Text
"Running filter " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack String
fp
       FilterCompleted String
fp Integer
ms -> Text
"Completed filter " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack String
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
          Text
" in " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (Integer -> String
forall a. Show a => a -> String
show Integer
ms) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" ms"
       CiteprocWarning Text
ms -> Text
"Citeproc: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ms
       ATXHeadingInLHS Int
lvl Text
contents ->
         Text
"Rendering heading '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
contents Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' as a paragraph.\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"ATX headings cannot be used in literate Haskell, because " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         Text
"'#' is not\nallowed in column 1." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
         if Int
lvl Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
3
            then Text
" Consider using --markdown-headings=setext."
            else Text
""
       EnvironmentVariableUndefined Text
var ->
         Text
"Undefined environment variable " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
var Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" in defaults file."
       DuplicateAttribute Text
attr Text
val ->
         Text
"Ignoring duplicate attribute " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
attr Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"=" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
forall a. Show a => a -> Text
tshow Text
val Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"."
       NotUTF8Encoded String
src ->
         String -> Text
Text.pack String
src Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
           Text
" is not UTF-8 encoded: falling back to latin1."

messageVerbosity :: LogMessage -> Verbosity
messageVerbosity :: LogMessage -> Verbosity
messageVerbosity LogMessage
msg =
  case LogMessage
msg of
       SkippedContent{}              -> Verbosity
INFO
       IgnoredElement{}              -> Verbosity
INFO
       DuplicateLinkReference{}      -> Verbosity
WARNING
       DuplicateNoteReference{}      -> Verbosity
WARNING
       NoteDefinedButNotUsed{}       -> Verbosity
WARNING
       DuplicateIdentifier{}         -> Verbosity
WARNING
       ReferenceNotFound{}           -> Verbosity
WARNING
       CircularReference{}           -> Verbosity
WARNING
       UndefinedToggle{}             -> Verbosity
WARNING
       CouldNotLoadIncludeFile Text
f SourcePos
_
        | Text
".sty" Text -> Text -> Bool
`Text.isSuffixOf` Text
f -> Verbosity
INFO
        | Bool
otherwise                  -> Verbosity
WARNING
       MacroAlreadyDefined{}         -> Verbosity
WARNING
       ParsingUnescaped{}            -> Verbosity
INFO
       InlineNotRendered{}           -> Verbosity
INFO
       BlockNotRendered{}            -> Verbosity
INFO
       DocxParserWarning{}           -> Verbosity
INFO
       PowerpointTemplateWarning{}   -> Verbosity
WARNING
       IgnoredIOError{}              -> Verbosity
WARNING
       CouldNotFetchResource{}       -> Verbosity
WARNING
       CouldNotDetermineImageSize{}  -> Verbosity
WARNING
       CouldNotConvertImage{}        -> Verbosity
WARNING
       CouldNotDetermineMimeType{}   -> Verbosity
WARNING
       CouldNotConvertTeXMath{}      -> Verbosity
WARNING
       CouldNotParseCSS{}            -> Verbosity
WARNING
       Fetching{}                    -> Verbosity
INFO
       Extracting{}                  -> Verbosity
INFO
       LoadedResource{}              -> Verbosity
INFO
       NoTitleElement{}              -> Verbosity
WARNING
       LogMessage
NoLangSpecified               -> Verbosity
INFO
       InvalidLang{}                 -> Verbosity
WARNING
       CouldNotHighlight{}           -> Verbosity
WARNING
       MissingCharacter{}            -> Verbosity
WARNING
       Deprecated{}                  -> Verbosity
WARNING
       NoTranslation{}               -> Verbosity
WARNING
       CouldNotLoadTranslations{}    -> Verbosity
WARNING
       UnusualConversion {}          -> Verbosity
WARNING
       UnexpectedXmlElement {}       -> Verbosity
WARNING
       UnknownOrgExportOption {}     -> Verbosity
WARNING
       CouldNotDeduceFormat{}        -> Verbosity
WARNING
       RunningFilter{}               -> Verbosity
INFO
       FilterCompleted{}             -> Verbosity
INFO
       CiteprocWarning{}             -> Verbosity
WARNING
       ATXHeadingInLHS{}             -> Verbosity
WARNING
       EnvironmentVariableUndefined{}-> Verbosity
WARNING
       DuplicateAttribute{}          -> Verbosity
WARNING
       NotUTF8Encoded{}              -> Verbosity
WARNING