use existing debug machinery for explain

explain is a kind of debug message, but not formatted in the same way.
So it makes sense to reuse the debug machinery for it, since that is
already quite optimised.

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2023-07-25 15:47:58 -04:00
parent fbf19338be
commit 409572c9e4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 49 additions and 16 deletions

View file

@ -50,6 +50,7 @@ module Messages (
outputMessage,
withMessageState,
MessageState,
explain,
prompt,
mkPrompter,
sanitizeTopLevelExceptionMessages,
@ -281,6 +282,11 @@ debugDisplayer = do
S.hPutStr stderr (safeOutput s <> "\n")
hFlush stderr
explain :: Maybe String -> String -> Annex ()
explain Nothing _ = return ()
explain (Just f) msg = fastDebug' "explain" $
RawDebugMessage ('[' : f ++ " " ++ msg ++ "]")
{- Should commands that normally output progress messages have that
- output disabled? -}
commandProgressDisabled :: Annex Bool