From 784e9eff8a87afa98dd9006b8dab267850f1480e Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 31 Mar 2014 07:58:28 -0700 Subject: [PATCH] dbg(ppshow) output improvements - align single-line output a little better - start multi-line output on a new line and indent it --- hledger-lib/Hledger/Utils.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Utils.hs b/hledger-lib/Hledger/Utils.hs index 442b12bdd..40f3a95b6 100644 --- a/hledger-lib/Hledger/Utils.hs +++ b/hledger-lib/Hledger/Utils.hs @@ -440,8 +440,14 @@ dbgshow level -- Values are displayed with ppShow, each field/constructor on its own line. dbgppshow :: Show a => Int -> String -> a -> a dbgppshow level - | debugLevel >= level = \s -> traceWith (((s++": ")++) . ppShow) - | otherwise = flip const + | debugLevel < level = flip const + | otherwise = \s a -> let p = ppShow a + ls = lines p + nlorspace | length ls > 1 = "\n" + | otherwise = " " ++ take (10 - length s) (repeat ' ') + ls' | length ls > 1 = map (" "++) ls + | otherwise = ls + in trace (s++":"++nlorspace++intercalate "\n" ls') a -- -- | Print a showable value to the console, with a message, if the -- -- debug level is at or above the specified level (uses