Skip to content

Commit

Permalink
Logging: add new log message type ScriptingInfo [API change]
Browse files Browse the repository at this point in the history
  • Loading branch information
tarleb committed Apr 18, 2024
1 parent 3d90234 commit 1c732c0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Text/Pandoc/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ data LogMessage =
| Fetching Text
| Extracting Text
| LoadedResource FilePath FilePath
| ScriptingInfo Text (Maybe SourcePos)
| ScriptingWarning Text (Maybe SourcePos)
| NoTitleElement Text
| NoLangSpecified
Expand Down Expand Up @@ -204,6 +205,14 @@ instance ToJSON LogMessage where
LoadedResource orig found ->
["for" .= orig
,"from" .= found]
ScriptingInfo msg mbpos ->
["message" .= msg] <>
case mbpos of
Nothing -> []
Just pos -> ["source" .= sourceName pos
,"line" .= toJSON (sourceLine pos)
,"column" .= toJSON (sourceColumn pos)
]
ScriptingWarning msg mbpos ->
["message" .= msg] <>
case mbpos of
Expand Down Expand Up @@ -349,6 +358,9 @@ showLogMessage msg =
"Extracting " <> fp <> "..."
LoadedResource orig found ->
"Loaded " <> Text.pack orig <> " from " <> Text.pack found
ScriptingInfo s mbpos ->
"Scripting info" <>
maybe "" (\pos -> " at " <> showPos pos) mbpos <> ": " <> s
ScriptingWarning s mbpos ->
"Scripting warning" <>
maybe "" (\pos -> " at " <> showPos pos) mbpos <> ": " <> s
Expand Down Expand Up @@ -446,6 +458,7 @@ messageVerbosity msg =
Fetching{} -> INFO
Extracting{} -> INFO
LoadedResource{} -> INFO
ScriptingInfo{} -> INFO
ScriptingWarning{} -> WARNING
NoTitleElement{} -> WARNING
NoLangSpecified -> INFO
Expand Down

0 comments on commit 1c732c0

Please sign in to comment.