dev: lib: support debug logging to file in a few more places for hledger-ui

This commit is contained in:
Simon Michael 2022-11-06 08:57:26 -10:00
parent 9a8a8a75a2
commit 78771e900b
3 changed files with 8 additions and 8 deletions

View File

@ -244,7 +244,7 @@ priceLookup makepricegraph d from mto =
,pgEdgesRev=allprices ,pgEdgesRev=allprices
,pgDefaultValuationCommodities=defaultdests ,pgDefaultValuationCommodities=defaultdests
} = } =
traceAt 1 ("valuation date: "++show d) $ makepricegraph d traceOrLogAt 1 ("valuation date: "++show d) $ makepricegraph d
mto' = mto <|> mdefaultto mto' = mto <|> mdefaultto
where where
mdefaultto = dbg1 ("default valuation commodity for "++T.unpack from) $ 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. -- according to the rules described in makePriceGraph.
let msg = printf "seeking %s to %s price" (showCommoditySymbol from) (showCommoditySymbol to) let msg = printf "seeking %s to %s price" (showCommoditySymbol from) (showCommoditySymbol to)
in case in case
(traceAt 2 (msg++" using forward prices") $ (traceOrLogAt 2 (msg++" using forward prices") $
pricesShortestPath from to forwardprices) pricesShortestPath from to forwardprices)
<|> <|>
(traceAt 2 (msg++" using forward and reverse prices") $ (traceOrLogAt 2 (msg++" using forward and reverse prices") $
pricesShortestPath from to allprices) pricesShortestPath from to allprices)
of of
Nothing -> Nothing Nothing -> Nothing

View File

@ -299,7 +299,7 @@ includedirectivep = do
Fail.fail ("Cyclic include: " ++ filepath) Fail.fail ("Cyclic include: " ++ filepath)
childInput <- childInput <-
traceAt 6 ("parseChild: "++takeFileName filepath) $ traceOrLogAt 6 ("parseChild: "++takeFileName filepath) $
lift $ readFilePortably filepath lift $ readFilePortably filepath
`orRethrowIOError` (show parentpos ++ " reading " ++ filepath) `orRethrowIOError` (show parentpos ++ " reading " ++ filepath)
let initChildj = newJournalWithParseStateFrom filepath parentj let initChildj = newJournalWithParseStateFrom filepath parentj

View File

@ -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 -- 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. -- 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) (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 -- maybe convert these transactions to cost or value
. journalApplyValuationFromOpts rspec . journalApplyValuationFromOpts rspec
. traceAtWith 5 (("ts2:\n"++).pshowTransactions.jtxns) . traceOrLogAtWith 5 (("ts2:\n"++).pshowTransactions.jtxns)
-- apply any cur:SYM filters in reportq -- apply any cur:SYM filters in reportq
. (if queryIsNull amtq then id else filterJournalAmounts amtq) . (if queryIsNull amtq then id else filterJournalAmounts amtq)
-- only consider transactions which match thisacctq (possibly excluding postings -- only consider transactions which match thisacctq (possibly excluding postings
-- which are not real or have the wrong status) -- which are not real or have the wrong status)
. traceAt 3 ("thisacctq: "++show thisacctq) . traceOrLogAt 3 ("thisacctq: "++show thisacctq)
$ traceAtWith 5 (("ts1:\n"++).pshowTransactions.jtxns) $ traceOrLogAtWith 5 (("ts1:\n"++).pshowTransactions.jtxns)
j{jtxns = filter (matchesTransaction thisacctq . relevantPostings) $ jtxns j} j{jtxns = filter (matchesTransaction thisacctq . relevantPostings) $ jtxns j}
where where
relevantPostings relevantPostings