imp: lib: dlog

This commit is contained in:
Simon Michael 2021-11-20 07:49:41 -10:00
parent d0c937a41b
commit 3c889cb565

View File

@ -93,7 +93,7 @@ module Hledger.Utils.Debug (
,module Debug.Trace
,useColorOnStdout
,useColorOnStderr
)
,dlog)
where
import Control.Monad (when)
@ -305,6 +305,10 @@ ptraceAtWith level f
-- in trace (s++":"++nlorspace++intercalate "\n" ls') a
in trace p a
-- | Log a pretty-printed showable value to "./debug.log". Uses unsafePerformIO.
dlog :: Show a => a -> a
dlog x = unsafePerformIO $ appendFile "debug.log" (pshow x ++ "\n") >> return x
-- "dbg" would clash with megaparsec.
-- | Pretty-print a label and the showable value to the console, then return it.
dbg0 :: Show a => String -> a -> a