diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index 988943fbc..a77a6b291 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -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