{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE OverloadedStrings  #-}
{- |
   Module      : Text.Pandoc.Logging
   Copyright   : Copyright (C) 2006-2023 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.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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [Verbosity] -> ShowS
$cshowList :: [Verbosity] -> ShowS
show :: Verbosity -> [Char]
$cshow :: Verbosity -> [Char]
showsPrec :: Int -> Verbosity -> ShowS
$cshowsPrec :: Int -> Verbosity -> ShowS
Show, ReadPrec [Verbosity]
ReadPrec Verbosity
Int -> ReadS Verbosity
ReadS [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
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
Verbosity -> DataType
Verbosity -> Constr
(forall b. Data b => b -> b) -> Verbosity -> 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)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(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 (m :: * -> *).
MonadPlus m =>
(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 (m :: * -> *).
Monad m =>
(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 :: forall u. Int -> (forall d. Data d => d -> u) -> Verbosity -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Verbosity -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Verbosity -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Verbosity -> [u]
gmapQr :: forall r r'.
(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 :: forall r r'.
(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 (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(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 (t :: * -> *) (c :: * -> *).
Typeable t =>
(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 (c :: * -> *).
(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 (c :: * -> *).
(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
Data, Int -> Verbosity
Verbosity -> Int
Verbosity -> [Verbosity]
Verbosity -> Verbosity
Verbosity -> Verbosity -> [Verbosity]
Verbosity -> Verbosity -> Verbosity -> [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
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
Ord, Verbosity
forall a. a -> a -> Bounded a
maxBound :: Verbosity
$cmaxBound :: Verbosity
minBound :: Verbosity
$cminBound :: Verbosity
Bounded, Typeable, 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 = forall a. ToJSON a => a -> Value
toJSON (forall a. Show a => a -> [Char]
show Verbosity
x)
instance FromJSON Verbosity where
  parseJSON :: Value -> Parser Verbosity
parseJSON (String Text
t) =
    case Text
t of
         Text
"ERROR"   -> forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
ERROR
         Text
"WARNING" -> forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
WARNING
         Text
"INFO"    -> forall (m :: * -> *) a. Monad m => a -> m a
return Verbosity
INFO
         Text
_         -> forall (m :: * -> *) a. MonadPlus m => m a
mzero
  parseJSON Value
_      =  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
  | CouldNotParseIncludeFile 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
  | ScriptingWarning Text (Maybe SourcePos)
  | 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 -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [LogMessage] -> ShowS
$cshowList :: [LogMessage] -> ShowS
show :: LogMessage -> [Char]
$cshow :: LogMessage -> [Char]
showsPrec :: Int -> LogMessage -> ShowS
$cshowsPrec :: Int -> LogMessage -> ShowS
Show, LogMessage -> LogMessage -> Bool
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
LogMessage -> DataType
LogMessage -> Constr
(forall b. Data b => b -> b) -> LogMessage -> 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)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(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 (m :: * -> *).
MonadPlus m =>
(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 (m :: * -> *).
Monad m =>
(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 :: forall u. Int -> (forall d. Data d => d -> u) -> LogMessage -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> LogMessage -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> LogMessage -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> LogMessage -> [u]
gmapQr :: forall r r'.
(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 :: forall r r'.
(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 (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(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 (t :: * -> *) (c :: * -> *).
Typeable t =>
(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 (c :: * -> *).
(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 (c :: * -> *).
(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
Data, Eq 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
Ord, Typeable, 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 forall a b. (a -> b) -> a -> b
$
    Key
"verbosity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (LogMessage -> Verbosity
messageVerbosity LogMessage
x) forall a. a -> [a] -> [a]
:
    Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (forall a. Show a => a -> [Char]
show forall a b. (a -> b) -> a -> b
$ forall a. Data a => a -> Constr
toConstr LogMessage
x) forall a. a -> [a] -> [a]
:
    case LogMessage
x of
      SkippedContent Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> Int
sourceLine SourcePos
pos,
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> Int
sourceColumn SourcePos
pos]
      IgnoredElement Text
s ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      DuplicateLinkReference Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      NoteDefinedButNotUsed Text
s SourcePos
pos ->
           [Key
"key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      DuplicateNoteReference Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      DuplicateIdentifier Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      ReferenceNotFound Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      CircularReference Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      UndefinedToggle Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      ParsingUnescaped Text
s SourcePos
pos ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      CouldNotLoadIncludeFile Text
fp SourcePos
pos ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      CouldNotParseIncludeFile Text
fp SourcePos
pos ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      MacroAlreadyDefined Text
name SourcePos
pos ->
           [Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
name,
            Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos,
            Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos),
            Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)]
      InlineNotRendered Inline
il ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON Inline
il]
      BlockNotRendered Block
bl ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON Block
bl]
      DocxParserWarning Text
s ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      PowerpointTemplateWarning Text
s ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      IgnoredIOError Text
s ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotFetchResource Text
fp Text
s ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotDetermineImageSize Text
fp Text
s ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotConvertImage Text
fp Text
s ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp,
            Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotDetermineMimeType Text
fp ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp]
      CouldNotConvertTeXMath Text
s Text
msg ->
           [Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s,
            Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      CouldNotParseCSS Text
msg ->
           [Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      Fetching Text
fp ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp]
      Extracting Text
fp ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fp]
      LoadedResource [Char]
orig [Char]
found ->
           [Key
"for"  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Char]
orig
           ,Key
"from" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Char]
found]
      ScriptingWarning Text
msg Maybe SourcePos
mbpos ->
           [Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg] forall a. Semigroup a => a -> a -> a
<>
           case Maybe SourcePos
mbpos of
             Maybe SourcePos
Nothing  -> []
             Just SourcePos
pos -> [Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SourcePos -> [Char]
sourceName SourcePos
pos
                         ,Key
"line" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceLine SourcePos
pos)
                         ,Key
"column" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON (SourcePos -> Int
sourceColumn SourcePos
pos)
                         ]
      NoTitleElement Text
fallback ->
           [Key
"fallback" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
fallback]
      LogMessage
NoLangSpecified -> []
      InvalidLang Text
s ->
           [Key
"lang" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
s]
      CouldNotHighlight Text
msg ->
           [Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      MissingCharacter Text
msg ->
           [Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      Deprecated Text
thing Text
msg ->
           [Key
"thing" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
thing,
            Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      NoTranslation Text
term ->
           [Key
"term" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
term]
      CouldNotLoadTranslations Text
lang Text
msg ->
           [Key
"lang" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
lang,
            Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      UnusualConversion Text
msg ->
           [Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      UnexpectedXmlElement Text
element Text
parent ->
           [Key
"element" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
element,
            Key
"parent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
parent]
      UnknownOrgExportOption Text
option ->
           [Key
"option" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
option]
      CouldNotDeduceFormat [Text]
exts Text
format ->
           [Key
"extensions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
exts
           ,Key
"format" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
format]
      RunningFilter [Char]
fp ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Char] -> Text
Text.pack [Char]
fp ]
      FilterCompleted [Char]
fp Integer
ms ->
           [Key
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Char] -> Text
Text.pack [Char]
fp
           ,Key
"milliseconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Char] -> Text
Text.pack (forall a. Show a => a -> [Char]
show Integer
ms) ]
      CiteprocWarning Text
msg ->
           [Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg]
      ATXHeadingInLHS Int
lvl Text
contents ->
           [Key
"level" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
lvl
           ,Key
"contents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
contents]
      EnvironmentVariableUndefined Text
var ->
           [Key
"variable" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
var ]
      DuplicateAttribute Text
attr Text
val ->
           [Key
"attribute" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
attr
           ,Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
val]
      NotUTF8Encoded [Char]
src ->
           [Key
"source" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Char]
src]

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

encodeLogMessages :: [LogMessage] -> BL.ByteString
encodeLogMessages :: [LogMessage] -> ByteString
encodeLogMessages [LogMessage]
ms =
  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 '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       IgnoredElement Text
s ->
         Text
"Ignored element " forall a. Semigroup a => a -> a -> a
<> Text
s
       DuplicateLinkReference Text
s SourcePos
pos ->
         Text
"Duplicate link reference '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       DuplicateNoteReference Text
s SourcePos
pos ->
         Text
"Duplicate note reference '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       NoteDefinedButNotUsed Text
s SourcePos
pos ->
         Text
"Note with key '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' defined at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos forall a. Semigroup a => a -> a -> a
<>
           Text
" but not used."
       DuplicateIdentifier Text
s SourcePos
pos ->
         Text
"Duplicate identifier '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       ReferenceNotFound Text
s SourcePos
pos ->
         Text
"Reference not found for '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       CircularReference Text
s SourcePos
pos ->
         Text
"Circular reference '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       UndefinedToggle Text
s SourcePos
pos ->
         Text
"Undefined toggle '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       ParsingUnescaped Text
s SourcePos
pos ->
         Text
"Parsing unescaped '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"' at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       CouldNotLoadIncludeFile Text
fp SourcePos
pos ->
         Text
"Could not load include file " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<> Text
" at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       CouldNotParseIncludeFile Text
fp SourcePos
pos ->
         Text
"Parsing include file " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<> Text
" failed at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       MacroAlreadyDefined Text
name SourcePos
pos ->
         Text
"Macro '" forall a. Semigroup a => a -> a -> a
<> Text
name forall a. Semigroup a => a -> a -> a
<> Text
"' already defined, ignoring at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos
       InlineNotRendered Inline
il ->
         Text
"Not rendering " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack (forall a. Show a => a -> [Char]
show Inline
il)
       BlockNotRendered Block
bl ->
         Text
"Not rendering " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack (forall a. Show a => a -> [Char]
show Block
bl)
       DocxParserWarning Text
s ->
         Text
"Docx parser warning: " forall a. Semigroup a => a -> a -> a
<> Text
s
       PowerpointTemplateWarning Text
s ->
         Text
"Powerpoint template warning: " forall a. Semigroup a => a -> a -> a
<> Text
s
       IgnoredIOError Text
s ->
         Text
"IO Error (ignored): " forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotFetchResource Text
fp Text
s ->
         Text
"Could not fetch resource " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
s then Text
"" else Text
": " forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotDetermineImageSize Text
fp Text
s ->
         Text
"Could not determine image size for " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
s then Text
"" else Text
": " forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotConvertImage Text
fp Text
s ->
         Text
"Could not convert image " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
s then Text
"" else Text
": " forall a. Semigroup a => a -> a -> a
<> Text
s
       CouldNotDetermineMimeType Text
fp ->
         Text
"Could not determine mime type for " forall a. Semigroup a => a -> a -> a
<> Text
fp
       CouldNotConvertTeXMath Text
s Text
m ->
         Text
"Could not convert TeX math " forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
", rendering as TeX" forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
m then Text
"" else Text
":\n" forall a. Semigroup a => a -> a -> a
<> Text
m
       CouldNotParseCSS Text
m ->
         Text
"Could not parse CSS" forall a. Semigroup a => a -> a -> a
<> if Text -> Bool
Text.null Text
m then Text
"" else Text
":\n" forall a. Semigroup a => a -> a -> a
<> Text
m
       Fetching Text
fp ->
         Text
"Fetching " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<> Text
"..."
       Extracting Text
fp ->
         Text
"Extracting " forall a. Semigroup a => a -> a -> a
<> Text
fp forall a. Semigroup a => a -> a -> a
<> Text
"..."
       LoadedResource [Char]
orig [Char]
found ->
         Text
"Loaded " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack [Char]
orig forall a. Semigroup a => a -> a -> a
<> Text
" from " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack [Char]
found
       ScriptingWarning Text
s Maybe SourcePos
mbpos ->
         Text
"Scripting warning" forall a. Semigroup a => a -> a -> a
<>
         forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
"" (\SourcePos
pos -> Text
" at " forall a. Semigroup a => a -> a -> a
<> SourcePos -> Text
showPos SourcePos
pos) Maybe SourcePos
mbpos  forall a. Semigroup a => a -> a -> a
<> Text
": " forall a. Semigroup a => a -> a -> a
<> Text
s
       NoTitleElement Text
fallback ->
         Text
"This document format requires a nonempty <title> element.\n" forall a. Semigroup a => a -> a -> a
<>
         Text
"Defaulting to '" forall a. Semigroup a => a -> a -> a
<> Text
fallback forall a. Semigroup a => a -> a -> a
<> Text
"' as the title.\n" forall a. Semigroup a => a -> a -> a
<>
         Text
"To specify a title, use 'title' in metadata or " forall a. Semigroup a => a -> a -> a
<>
         Text
"--metadata title=\"...\"."
       LogMessage
NoLangSpecified ->
         Text
"No value for 'lang' was specified in the metadata.\n" 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 '" forall a. Semigroup a => a -> a -> a
<> Text
s forall a. Semigroup a => a -> a -> a
<> Text
"'.\n" 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" forall a. Semigroup a => a -> a -> a
<> Text
m
       MissingCharacter Text
m ->
         Text
"Missing character: " forall a. Semigroup a => a -> a -> a
<> Text
m
       Deprecated Text
t Text
m ->
         Text
"Deprecated: " forall a. Semigroup a => a -> a -> a
<> Text
t forall a. Semigroup a => a -> a -> a
<>
         if Text -> Bool
Text.null Text
m
            then Text
""
            else Text
". " forall a. Semigroup a => a -> a -> a
<> Text
m
       NoTranslation Text
t ->
         Text
"The term " forall a. Semigroup a => a -> a -> a
<> Text
t forall a. Semigroup a => a -> a -> a
<> Text
" has no translation defined."
       CouldNotLoadTranslations Text
lang Text
m ->
         Text
"Could not load translations for " forall a. Semigroup a => a -> a -> a
<> Text
lang forall a. Semigroup a => a -> a -> a
<>
           if Text -> Bool
Text.null Text
m then Text
"" else Text
"\n" forall a. Semigroup a => a -> a -> a
<> Text
m
       UnusualConversion Text
m ->
         Text
"Unusual conversion: " forall a. Semigroup a => a -> a -> a
<> Text
m
       UnexpectedXmlElement Text
element Text
parent ->
         Text
"Unexpected XML element " forall a. Semigroup a => a -> a -> a
<> Text
element forall a. Semigroup a => a -> a -> a
<> Text
" in " forall a. Semigroup a => a -> a -> a
<> Text
parent
       UnknownOrgExportOption Text
option ->
         Text
"Ignoring unknown Org export option: " forall a. Semigroup a => a -> a -> a
<> Text
option
       CouldNotDeduceFormat [Text]
exts Text
format ->
         Text
"Could not deduce format from file extension " forall a. Semigroup a => a -> a -> a
<>
         Text -> [Text] -> Text
Text.intercalate Text
" or " [Text]
exts forall a. Semigroup a => a -> a -> a
<> Text
"\n" forall a. Semigroup a => a -> a -> a
<>
         Text
"Defaulting to " forall a. Semigroup a => a -> a -> a
<> Text
format
       RunningFilter [Char]
fp -> Text
"Running filter " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack [Char]
fp
       FilterCompleted [Char]
fp Integer
ms -> Text
"Completed filter " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack [Char]
fp forall a. Semigroup a => a -> a -> a
<>
          Text
" in " forall a. Semigroup a => a -> a -> a
<> [Char] -> Text
Text.pack (forall a. Show a => a -> [Char]
show Integer
ms) forall a. Semigroup a => a -> a -> a
<> Text
" ms"
       CiteprocWarning Text
ms -> Text
"Citeproc: " forall a. Semigroup a => a -> a -> a
<> Text
ms
       ATXHeadingInLHS Int
lvl Text
contents ->
         Text
"Rendering heading '" forall a. Semigroup a => a -> a -> a
<> Text
contents forall a. Semigroup a => a -> a -> a
<> Text
"' as a paragraph.\n" forall a. Semigroup a => a -> a -> a
<>
         Text
"ATX headings cannot be used in literate Haskell, because " forall a. Semigroup a => a -> a -> a
<>
         Text
"'#' is not\nallowed in column 1." forall a. Semigroup a => a -> a -> a
<>
         if Int
lvl 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 " forall a. Semigroup a => a -> a -> a
<> Text
var forall a. Semigroup a => a -> a -> a
<> Text
" in defaults file."
       DuplicateAttribute Text
attr Text
val ->
         Text
"Ignoring duplicate attribute " forall a. Semigroup a => a -> a -> a
<> Text
attr forall a. Semigroup a => a -> a -> a
<> Text
"=" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
tshow Text
val forall a. Semigroup a => a -> a -> a
<> Text
"."
       NotUTF8Encoded [Char]
src ->
         [Char] -> Text
Text.pack [Char]
src 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
       CouldNotParseIncludeFile{}    -> 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
       ScriptingWarning{}            -> Verbosity
WARNING
       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