@@ -43,7 +43,7 @@ import Data.Aeson
4343import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',
4444 keyOrder)
4545import qualified Data.ByteString.Lazy as BL
46−import Data.Data (Data)
46+import Data.Data (Data, toConstr)
4747import Data.Generics (Typeable)
4848import qualified Data.Text as Text
4949import GHC.Generics (Generic)
@@ -78,102 +78,86 @@ data LogMessage =
7878 | CouldNotParseCSS String
7979 | Fetching String
8080 | NoTitleElement String
81+ | NoLangSpecified
8182 deriving (Show, Eq, Data, Ord, Typeable, Generic)
8283
8384instance ToJSON LogMessage where
84− toJSON x = object $ "verbosity" .= toJSON (messageVerbosity x) :
85+ toJSON x = object $
86+ "verbosity" .= toJSON (messageVerbosity x) :
87+ "type" .= toJSON (show $ toConstr x) :
8588 case x of
8689 SkippedContent s pos ->
87− ["type" .= String "SkippedContent",
88− "contents" .= Text.pack s,
90+ ["contents" .= Text.pack s,
8991 "source" .= Text.pack (sourceName pos),
9092 "line" .= sourceLine pos,
9193 "column" .= sourceColumn pos]
9294 CouldNotParseYamlMetadata s pos ->
93− ["type" .= String "YamlSectionNotAnObject",
94− "message" .= Text.pack s,
95+ ["message" .= Text.pack s,
9596 "source" .= Text.pack (sourceName pos),
9697 "line" .= toJSON (sourceLine pos),
9798 "column" .= toJSON (sourceColumn pos)]
9899 DuplicateLinkReference s pos ->
99− ["type" .= String "DuplicateLinkReference",
100− "contents" .= Text.pack s,
100+ ["contents" .= Text.pack s,
101101 "source" .= Text.pack (sourceName pos),
102102 "line" .= toJSON (sourceLine pos),
103103 "column" .= toJSON (sourceColumn pos)]
104104 DuplicateNoteReference s pos ->
105− ["type" .= String "DuplicateNoteReference",
106− "contents" .= Text.pack s,
105+ ["contents" .= Text.pack s,
107106 "source" .= Text.pack (sourceName pos),
108107 "line" .= toJSON (sourceLine pos),
109108 "column" .= toJSON (sourceColumn pos)]
110109 ReferenceNotFound s pos ->
111− ["type" .= String "ReferenceNotFound",
112− "contents" .= Text.pack s,
110+ ["contents" .= Text.pack s,
113111 "source" .= Text.pack (sourceName pos),
114112 "line" .= toJSON (sourceLine pos),
115113 "column" .= toJSON (sourceColumn pos)]
116114 CircularReference s pos ->
117− ["type" .= String "CircularReference",
118− "contents" .= Text.pack s,
115+ ["contents" .= Text.pack s,
119116 "source" .= Text.pack (sourceName pos),
120117 "line" .= toJSON (sourceLine pos),
121118 "column" .= toJSON (sourceColumn pos)]
122119 ParsingUnescaped s pos ->
123− ["type" .= String "ParsingUnescaped",
124− "contents" .= Text.pack s,
120+ ["contents" .= Text.pack s,
125121 "source" .= Text.pack (sourceName pos),
126122 "line" .= toJSON (sourceLine pos),
127123 "column" .= toJSON (sourceColumn pos)]
128124 CouldNotLoadIncludeFile fp pos ->
129− ["type" .= String "CouldNotLoadIncludeFile",
130− "path" .= Text.pack fp,
125+ ["path" .= Text.pack fp,
131126 "source" .= Text.pack (sourceName pos),
132127 "line" .= toJSON (sourceLine pos),
133128 "column" .= toJSON (sourceColumn pos)]
134129 ParsingTrace s pos ->
135− ["type" .= String "ParsingTrace",
136− "contents" .= Text.pack s,
130+ ["contents" .= Text.pack s,
137131 "source" .= Text.pack (sourceName pos),
138132 "line" .= sourceLine pos,
139133 "column" .= sourceColumn pos]
140134 InlineNotRendered il ->
141− ["type" .= String "InlineNotRendered",
142− "contents" .= toJSON il]
135+ ["contents" .= toJSON il]
143136 BlockNotRendered bl ->
144− ["type" .= String "BlockNotRendered",
145− "contents" .= toJSON bl]
137+ ["contents" .= toJSON bl]
146138 DocxParserWarning s ->
147− ["type" .= String "DocxParserWarning",
148− "contents" .= Text.pack s]
139+ ["contents" .= Text.pack s]
149140 CouldNotFetchResource fp s ->
150− ["type" .= String "CouldNotFetchResource",
151− "path" .= Text.pack fp,
141+ ["path" .= Text.pack fp,
152142 "message" .= Text.pack s]
153143 CouldNotDetermineImageSize fp s ->
154− ["type" .= String "CouldNotDetermineImageSize",
155− "path" .= Text.pack fp,
144+ ["path" .= Text.pack fp,
156145 "message" .= Text.pack s]
157146 CouldNotConvertImage fp s ->
158− ["type" .= String "CouldNotConvertImage",
159− "path" .= Text.pack fp,
147+ ["path" .= Text.pack fp,
160148 "message" .= Text.pack s]
161149 CouldNotDetermineMimeType fp ->
162− ["type" .= String "CouldNotDetermineMimeType",
163− "path" .= Text.pack fp]
150+ ["path" .= Text.pack fp]
164151 CouldNotConvertTeXMath s msg ->
165− ["type" .= String "CouldNotConvertTeXMath",
166− "contents" .= Text.pack s,
152+ ["contents" .= Text.pack s,
167153 "message" .= Text.pack msg]
168154 CouldNotParseCSS msg ->
169− ["type" .= String "CouldNotParseCSS",
170− "message" .= Text.pack msg]
155+ ["message" .= Text.pack msg]
171156 Fetching fp ->
172− ["type" .= String "CouldNotParseCSS",
173− "path" .= Text.pack fp]
157+ ["path" .= Text.pack fp]
174158 NoTitleElement fallback ->
175− ["type" .= String "NoTitleElement",
176− "fallback" .= Text.pack fallback]
159+ ["fallback" .= Text.pack fallback]
160+ NoLangSpecified -> []
177161
178162showPos :: SourcePos -> String
179163showPos pos = sn ++ "line " ++
@@ -238,6 +222,9 @@ showLogMessage msg =
238222 "This document format requires a nonempty <title> element.\n" ++
239223 "Please specify either 'title' or 'pagetitle' in the metadata.\n" ++
240224 "Falling back to '" ++ fallback ++ "'"
225+ NoLangSpecified ->
226+ "No value for 'lang' was specified in the metadata.\n" ++
227+ "It is recommended that lang be specified for this format."
241228
242229messageVerbosity:: LogMessage -> Verbosity
243230messageVerbosity msg =
@@ -262,3 +249,4 @@ messageVerbosity msg =
262249 CouldNotParseCSS{} -> WARNING
263250 Fetching{} -> INFO
264251 NoTitleElement{} -> WARNING
252+ NoLangSpecified -> INFO