From 78771e900ba81b28a8f7ab8e7b35a265abb619d1 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 6 Nov 2022 08:57:26 -1000 Subject: [PATCH] dev: lib: support debug logging to file in a few more places for hledger-ui --- hledger-lib/Hledger/Data/Valuation.hs | 6 +++--- hledger-lib/Hledger/Read/JournalReader.hs | 2 +- hledger-lib/Hledger/Reports/AccountTransactionsReport.hs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hledger-lib/Hledger/Data/Valuation.hs b/hledger-lib/Hledger/Data/Valuation.hs index b87067e80..7af0116ee 100644 --- a/hledger-lib/Hledger/Data/Valuation.hs +++ b/hledger-lib/Hledger/Data/Valuation.hs @@ -244,7 +244,7 @@ priceLookup makepricegraph d from mto = ,pgEdgesRev=allprices ,pgDefaultValuationCommodities=defaultdests } = - traceAt 1 ("valuation date: "++show d) $ makepricegraph d + traceOrLogAt 1 ("valuation date: "++show d) $ makepricegraph d mto' = mto <|> mdefaultto where mdefaultto = dbg1 ("default valuation commodity for "++T.unpack from) $ @@ -258,10 +258,10 @@ priceLookup makepricegraph d from mto = -- according to the rules described in makePriceGraph. let msg = printf "seeking %s to %s price" (showCommoditySymbol from) (showCommoditySymbol to) in case - (traceAt 2 (msg++" using forward prices") $ + (traceOrLogAt 2 (msg++" using forward prices") $ pricesShortestPath from to forwardprices) <|> - (traceAt 2 (msg++" using forward and reverse prices") $ + (traceOrLogAt 2 (msg++" using forward and reverse prices") $ pricesShortestPath from to allprices) of Nothing -> Nothing diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index a7073ff99..a6718d1b9 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -299,7 +299,7 @@ includedirectivep = do Fail.fail ("Cyclic include: " ++ filepath) childInput <- - traceAt 6 ("parseChild: "++takeFileName filepath) $ + traceOrLogAt 6 ("parseChild: "++takeFileName filepath) $ lift $ readFilePortably filepath `orRethrowIOError` (show parentpos ++ " reading " ++ filepath) let initChildj = newJournalWithParseStateFrom filepath parentj diff --git a/hledger-lib/Hledger/Reports/AccountTransactionsReport.hs b/hledger-lib/Hledger/Reports/AccountTransactionsReport.hs index 91fe784c1..7c1ac3760 100644 --- a/hledger-lib/Hledger/Reports/AccountTransactionsReport.hs +++ b/hledger-lib/Hledger/Reports/AccountTransactionsReport.hs @@ -121,16 +121,16 @@ accountTransactionsReport rspec@ReportSpec{_rsReportOpts=ropts} j thisacctq = it -- want to keep prices around, so we can toggle between cost and no cost quickly. We can use -- the show_costs_ flag to be efficient when we can, and detailed when we have to. (if show_costs_ ropts then id else journalMapPostingAmounts mixedAmountStripPrices) - . traceAtWith 5 (("ts3:\n"++).pshowTransactions.jtxns) + . traceOrLogAtWith 5 (("ts3:\n"++).pshowTransactions.jtxns) -- maybe convert these transactions to cost or value . journalApplyValuationFromOpts rspec - . traceAtWith 5 (("ts2:\n"++).pshowTransactions.jtxns) + . traceOrLogAtWith 5 (("ts2:\n"++).pshowTransactions.jtxns) -- apply any cur:SYM filters in reportq . (if queryIsNull amtq then id else filterJournalAmounts amtq) -- only consider transactions which match thisacctq (possibly excluding postings -- which are not real or have the wrong status) - . traceAt 3 ("thisacctq: "++show thisacctq) - $ traceAtWith 5 (("ts1:\n"++).pshowTransactions.jtxns) + . traceOrLogAt 3 ("thisacctq: "++show thisacctq) + $ traceOrLogAtWith 5 (("ts1:\n"++).pshowTransactions.jtxns) j{jtxns = filter (matchesTransaction thisacctq . relevantPostings) $ jtxns j} where relevantPostings