Logging: add new log message type ScriptingInfo [API change]

This commit is contained in:
Albert Krewinkel
2024-05-10 19:03:29 -07:00
committed by John MacFarlane
parent e13845d085
commit 673edabac0
+13
View File
@@ -79,6 +79,7 @@ data LogMessage =
| Fetching Text
| Extracting Text
| LoadedResource FilePath FilePath
| ScriptingInfo Text (Maybe SourcePos)
| ScriptingWarning Text (Maybe SourcePos)
| NoTitleElement Text
| NoLangSpecified
@@ -205,6 +206,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
@@ -352,6 +361,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
@@ -451,6 +463,7 @@ messageVerbosity msg =
Fetching{} -> INFO
Extracting{} -> INFO
LoadedResource{} -> INFO
ScriptingInfo{} -> INFO
ScriptingWarning{} -> WARNING
NoTitleElement{} -> WARNING
NoLangSpecified -> INFO