@@ -52,31 +52,35 @@ instance ToJSON Verbosity where
52 toJSON x = toJSON (show x)
52 toJSON x = toJSON (show x)
54data LogMessage =
54data LogMessage =
55− SkippedInput String SourcePos
55+ SkippedContent String SourcePos
56− | YamlSectionNotAnObject SourcePos
56+ | CouldNotParseYamlMetadata String SourcePos
57 | DuplicateLinkReference String SourcePos
57 | DuplicateLinkReference String SourcePos
58 | DuplicateNoteReference String SourcePos
58 | DuplicateNoteReference String SourcePos
59+ | ReferenceNotFound String SourcePos
59 | ParsingUnescaped String SourcePos
60 | ParsingUnescaped String SourcePos
61+ | CouldNotLoadIncludeFile String SourcePos
62+ | ParsingTrace String SourcePos
60 | InlineNotRendered Inline
63 | InlineNotRendered Inline
61 | BlockNotRendered Block
64 | BlockNotRendered Block
62− | DocxCommentWillNotRetainFormatting String
65+ | DocxParserWarning String
63 | CouldNotFetchResource String String
66 | CouldNotFetchResource String String
64− | CouldNotDetermineImageSize String
67+ | CouldNotDetermineImageSize String String
65 | CouldNotDetermineMimeType String
68 | CouldNotDetermineMimeType String
66− | CouldNotConvertTeXMath String
69+ | CouldNotConvertTeXMath String String
67 deriving (Show, Eq, Data, Ord, Typeable, Generic)
70 deriving (Show, Eq, Data, Ord, Typeable, Generic)
69instance ToJSON LogMessage where
72instance ToJSON LogMessage where
70 toJSON x = object $ "verbosity" .= toJSON (messageVerbosity x) :
73 toJSON x = object $ "verbosity" .= toJSON (messageVerbosity x) :
72− SkippedInput s pos ->
75+ SkippedContent s pos ->
73− ["type" .= String "SkippedInput",
76+ ["type" .= String "SkippedContent",
74 "contents" .= Text.pack s,
77 "contents" .= Text.pack s,
75 "source" .= Text.pack (sourceName pos),
78 "source" .= Text.pack (sourceName pos),
76 "line" .= sourceLine pos,
79 "line" .= sourceLine pos,
77 "column" .= sourceColumn pos]
80 "column" .= sourceColumn pos]
78− YamlSectionNotAnObject pos ->
81+ CouldNotParseYamlMetadata s pos ->
79 ["type" .= String "YamlSectionNotAnObject",
82 ["type" .= String "YamlSectionNotAnObject",
83+ "message" .= Text.pack s,
80 "source" .= Text.pack (sourceName pos),
84 "source" .= Text.pack (sourceName pos),
81 "line" .= toJSON (sourceLine pos),
85 "line" .= toJSON (sourceLine pos),
82 "column" .= toJSON (sourceColumn pos)]
86 "column" .= toJSON (sourceColumn pos)]
@@ -92,75 +96,114 @@ instance ToJSON LogMessage where
92 "source" .= Text.pack (sourceName pos),
96 "source" .= Text.pack (sourceName pos),
93 "line" .= toJSON (sourceLine pos),
97 "line" .= toJSON (sourceLine pos),
94 "column" .= toJSON (sourceColumn pos)]
98 "column" .= toJSON (sourceColumn pos)]
99+ ReferenceNotFound s pos ->
100+ ["type" .= String "ReferenceNotFound",
101+ "contents" .= Text.pack s,
102+ "source" .= Text.pack (sourceName pos),
103+ "line" .= toJSON (sourceLine pos),
104+ "column" .= toJSON (sourceColumn pos)]
95 ParsingUnescaped s pos ->
105 ParsingUnescaped s pos ->
96 ["type" .= String "ParsingUnescaped",
106 ["type" .= String "ParsingUnescaped",
97 "contents" .= Text.pack s,
107 "contents" .= Text.pack s,
98 "source" .= Text.pack (sourceName pos),
108 "source" .= Text.pack (sourceName pos),
99 "line" .= toJSON (sourceLine pos),
109 "line" .= toJSON (sourceLine pos),
100 "column" .= toJSON (sourceColumn pos)]
110 "column" .= toJSON (sourceColumn pos)]
111+ CouldNotLoadIncludeFile fp pos ->
112+ ["type" .= String "CouldNotLoadIncludeFile",
113+ "path" .= Text.pack fp,
114+ "source" .= Text.pack (sourceName pos),
115+ "line" .= toJSON (sourceLine pos),
116+ "column" .= toJSON (sourceColumn pos)]
117+ ParsingTrace s pos ->
118+ ["type" .= String "ParsingTrace",
119+ "contents" .= Text.pack s,
120+ "source" .= Text.pack (sourceName pos),
121+ "line" .= sourceLine pos,
122+ "column" .= sourceColumn pos]
101 InlineNotRendered il ->
123 InlineNotRendered il ->
102 ["type" .= String "InlineNotRendered",
124 ["type" .= String "InlineNotRendered",
103 "contents" .= toJSON il]
125 "contents" .= toJSON il]
104 BlockNotRendered bl ->
126 BlockNotRendered bl ->
105 ["type" .= String "BlockNotRendered",
127 ["type" .= String "BlockNotRendered",
106 "contents" .= toJSON bl]
128 "contents" .= toJSON bl]
107− DocxCommentWillNotRetainFormatting s ->
129+ DocxParserWarning s ->
108− ["type" .= String "DocxCommentWillNotRetainFormatting",
130+ ["type" .= String "DocxParserWarning",
109− "commentId" .= Text.pack s]
131+ "contents" .= Text.pack s]
110 CouldNotFetchResource fp s ->
132 CouldNotFetchResource fp s ->
111 ["type" .= String "CouldNotFetchResource",
133 ["type" .= String "CouldNotFetchResource",
112 "path" .= Text.pack fp,
134 "path" .= Text.pack fp,
113 "message" .= Text.pack s]
135 "message" .= Text.pack s]
114− CouldNotDetermineImageSize fp ->
136+ CouldNotDetermineImageSize fp s ->
115 ["type" .= String "CouldNotDetermineImageSize",
137 ["type" .= String "CouldNotDetermineImageSize",
116− "path" .= Text.pack fp]
138+ "path" .= Text.pack fp,
139+ "message" .= Text.pack s]
117 CouldNotDetermineMimeType fp ->
140 CouldNotDetermineMimeType fp ->
118 ["type" .= String "CouldNotDetermineMimeType",
141 ["type" .= String "CouldNotDetermineMimeType",
119 "path" .= Text.pack fp]
142 "path" .= Text.pack fp]
120− CouldNotConvertTeXMath s ->
143+ CouldNotConvertTeXMath s msg ->
121 ["type" .= String "CouldNotConvertTeXMath",
144 ["type" .= String "CouldNotConvertTeXMath",
122− "contents" .= Text.pack s]
145+ "contents" .= Text.pack s,
146+ "message" .= Text.pack msg]
148+showPos :: SourcePos -> String
149+showPos pos = sn ++ "line " ++
150+ show (sourceLine pos) ++ " column " ++ show (sourceColumn pos)
151+ where sn = if sourceName pos == "source" || sourceName pos == ""
153+ else sourceName pos ++ " "
124showLogMessage :: LogMessage -> String
155showLogMessage :: LogMessage -> String
125showLogMessage msg =
156showLogMessage msg =
126 case msg of
157 case msg of
127− SkippedInput s pos ->
158+ SkippedContent s pos ->
128− "Skipped '" ++ s ++ "' at " ++ show pos
159+ "Skipped '" ++ s ++ "' at " ++ showPos pos
129− YamlSectionNotAnObject pos ->
160+ CouldNotParseYamlMetadata s pos ->
130− "YAML metadata section is not an object at " ++ show pos
161+ "Could not parse YAML metadata at " ++ showPos pos ++
162+ if null s then "" else (": " ++ s)
131 DuplicateLinkReference s pos ->
163 DuplicateLinkReference s pos ->
132− "Duplicate link reference '" ++ s ++ "' at " ++ show pos
164+ "Duplicate link reference '" ++ s ++ "' at " ++ showPos pos
133 DuplicateNoteReference s pos ->
165 DuplicateNoteReference s pos ->
134− "Duplicate note reference '" ++ s ++ "' at " ++ show pos
166+ "Duplicate note reference '" ++ s ++ "' at " ++ showPos pos
167+ ReferenceNotFound s pos ->
168+ "Reference not found for '" ++ s ++ "' at " ++ showPos pos
135 ParsingUnescaped s pos ->
169 ParsingUnescaped s pos ->
136− "Parsing unescaped '" ++ s ++ "' at " ++ show pos
170+ "Parsing unescaped '" ++ s ++ "' at " ++ showPos pos
171+ CouldNotLoadIncludeFile fp pos ->
172+ "Could not load include file '" ++ fp ++ "' at " ++ showPos pos
173+ ParsingTrace s pos ->
174+ "Parsing trace at " ++ showPos pos ++ ": " ++ s
137 InlineNotRendered il ->
175 InlineNotRendered il ->
138 "Not rendering " ++ show il
176 "Not rendering " ++ show il
139 BlockNotRendered bl ->
177 BlockNotRendered bl ->
140 "Not rendering " ++ show bl
178 "Not rendering " ++ show bl
141− DocxCommentWillNotRetainFormatting s ->
179+ DocxParserWarning s ->
142− "Docx comment with id '" ++ s ++ "' will not retain formatting"
180+ "Docx parser warning: " ++ s
143 CouldNotFetchResource fp s ->
181 CouldNotFetchResource fp s ->
144 "Could not fetch resource '" ++ fp ++ "'" ++
182 "Could not fetch resource '" ++ fp ++ "'" ++
145 if null s then "" else (": " ++ s)
183 if null s then "" else (": " ++ s)
146− CouldNotDetermineImageSize fp ->
184+ CouldNotDetermineImageSize fp s ->
147− "Could not determine image size for '" ++ fp ++ "'"
185+ "Could not determine image size for '" ++ fp ++ "'" ++
186+ if null s then "" else (": " ++ s)
148 CouldNotDetermineMimeType fp ->
187 CouldNotDetermineMimeType fp ->
149 "Could not determine mime type for '" ++ fp ++ "'"
188 "Could not determine mime type for '" ++ fp ++ "'"
150− CouldNotConvertTeXMath s ->
189+ CouldNotConvertTeXMath s m ->
151− "Could not convert TeX math '" ++ s ++ "', rendering as TeX"
190+ "Could not convert TeX math '" ++ s ++ "', rendering as TeX" ++
191+ if null m then "" else (':':'\n':m)
153messageVerbosity:: LogMessage -> Verbosity
193messageVerbosity:: LogMessage -> Verbosity
154messageVerbosity msg =
194messageVerbosity msg =
155 case msg of
195 case msg of
156− SkippedInput{} -> INFO
196+ SkippedContent{} -> INFO
157− YamlSectionNotAnObject{} -> WARNING
197+ CouldNotParseYamlMetadata{} -> WARNING
158 DuplicateLinkReference{} -> WARNING
198 DuplicateLinkReference{} -> WARNING
159 DuplicateNoteReference{} -> WARNING
199 DuplicateNoteReference{} -> WARNING
200+ ReferenceNotFound{} -> WARNING
201+ CouldNotLoadIncludeFile{} -> WARNING
160 ParsingUnescaped{} -> INFO
202 ParsingUnescaped{} -> INFO
203+ ParsingTrace{} -> DEBUG
161 InlineNotRendered{} -> INFO
204 InlineNotRendered{} -> INFO
162 BlockNotRendered{} -> INFO
205 BlockNotRendered{} -> INFO
163− DocxCommentWillNotRetainFormatting{} -> INFO
206+ DocxParserWarning{} -> WARNING
164 CouldNotFetchResource{} -> WARNING
207 CouldNotFetchResource{} -> WARNING
165 CouldNotDetermineImageSize{} -> WARNING
208 CouldNotDetermineImageSize{} -> WARNING
166 CouldNotDetermineMimeType{} -> WARNING
209 CouldNotDetermineMimeType{} -> WARNING