fix: traceOrLog and a rare warning from valuation code
Hledger.Utils.Debug.traceOrLog was logging when it should trace and vice versa. This affected a warning which Hledger.Data.Valuation.pricesShortestPath should display if encountering a pathologically long (>1000) price chain. Also note some oddities about that warning.
This commit is contained in:
parent
42c7383f57
commit
8f6b7b202e
@ -364,6 +364,12 @@ pricesShortestPath start end edges =
|
||||
case concatMap extend paths of
|
||||
[] -> Nothing
|
||||
_ | pathlength > maxpathlength ->
|
||||
-- XXX This is unusual:
|
||||
-- 1. A warning, not an error, which we usually avoid
|
||||
-- 2. Not a debug message (when triggered, we always print it)
|
||||
-- 3. Printed either to stdout or (eg in hledger-ui) to the debug log file.
|
||||
-- This is the only place we use traceOrLog like this.
|
||||
-- Also before 1.32.2, traceOrLog was doing the opposite of what it should [#2134].
|
||||
traceOrLog ("gave up searching for a price chain at length "++show maxpathlength++", please report a bug")
|
||||
Nothing
|
||||
where
|
||||
|
||||
@ -332,7 +332,7 @@ ptraceLogAtIO level label a =
|
||||
-- | Trace or log a string depending on shouldLog,
|
||||
-- before returning the second argument.
|
||||
traceOrLog :: String -> a -> a
|
||||
traceOrLog = if shouldLog then trace else traceLog
|
||||
traceOrLog = if shouldLog then traceLog else trace
|
||||
|
||||
-- | Trace or log a string depending on shouldLog,
|
||||
-- when global debug level is at or above the specified level,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user