From 1ad919bc6dfcb5e8d62f3b26479b0cb6a3c41238 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 7 Jan 2021 08:57:25 -0800 Subject: [PATCH] lib: add level argument to fix traceAtWith --- hledger-lib/Hledger/Utils/Debug.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index bdb080d0a..f3d3be32a 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -168,9 +168,11 @@ traceAt level | level > 0 && debugLevel < level = flip const | otherwise = trace --- | Trace (print to stderr) a showable value using a custom show function. -traceAtWith :: (a -> String) -> a -> a -traceAtWith f a = trace (f a) a +-- | Trace (print to stderr) a showable value using a custom show function, +-- if the global debug level is at or above the specified level. +-- At level 0, always prints. Otherwise, uses unsafePerformIO. +traceAtWith :: Int -> (a -> String) -> a -> a +traceAtWith level f a = traceAt level (f a) a -- | Pretty-print a label and a showable value to the console -- if the global debug level is at or above the specified level.