From 613efba1bc700b98b55356cf503ad6de5045e9da Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Mon, 21 Jun 2021 16:43:23 +1000 Subject: [PATCH] ui: Do not log to debug.log when regenerating journal in Transaction screen (#1556). Also really clear cost setting when doing so. Since plog is no longer used anywhere, and tends to create bugs when it is, we remove it. --- hledger-lib/Hledger/Utils/Debug.hs | 34 ------------------------------ hledger-ui/Hledger/UI/UIState.hs | 2 +- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index a072973dc..6341a69ec 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -87,9 +87,6 @@ module Hledger.Utils.Debug ( ,dbg7IO ,dbg8IO ,dbg9IO - -- ** Trace to a file - ,plog - ,plogAt -- ** Trace the state of hledger parsers ,traceParse ,dbgparse @@ -422,37 +419,6 @@ dbg8IO = ptraceAtIO 8 dbg9IO :: (MonadIO m, Show a) => String -> a -> m () dbg9IO = ptraceAtIO 9 --- | Log a label and a pretty-printed showable value to ./debug.log, then return it. --- Can fail, see plogAt. -plog :: Show a => String -> a -> a -plog = plogAt 0 - --- | Log a label and a pretty-printed showable value to ./debug.log, --- if the global debug level is at or above the specified level. --- At level 0, always logs. Otherwise, uses unsafePerformIO. --- Tends to fail if called more than once too quickly, at least when built with -threaded --- ("Exception: debug.log: openFile: resource busy (file is locked)"). -plogAt :: Show a => Int -> String -> a -> a -plogAt lvl - | lvl > 0 && debugLevel < lvl = flip const - | otherwise = \s a -> - let p = pshow a - ls = lines p - nlorspace | length ls > 1 = "\n" - | otherwise = " " ++ take (10 - length s) (repeat ' ') - ls' | length ls > 1 = map (" "++) ls - | otherwise = ls - output = s++":"++nlorspace++intercalate "\n" ls'++"\n" - in unsafePerformIO $ appendFile "debug.log" output >> return a - --- XXX redundant ? More/less robust than plogAt ? --- -- | Like dbg, but writes the output to "debug.log" in the current directory. --- dbglog :: Show a => String -> a -> a --- dbglog label a = --- (unsafePerformIO $ --- appendFile "debug.log" $ label ++ ": " ++ ppShow a ++ "\n") --- `seq` a - -- | Print the provided label (if non-null) and current parser state -- (position and next input) to the console. See also megaparsec's dbg. traceParse :: String -> TextParser m () diff --git a/hledger-ui/Hledger/UI/UIState.hs b/hledger-ui/Hledger/UI/UIState.hs index ee48f1dc4..1e6a02550 100644 --- a/hledger-ui/Hledger/UI/UIState.hs +++ b/hledger-ui/Hledger/UI/UIState.hs @@ -108,7 +108,7 @@ toggleEmpty ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rsp -- | Show primary amounts, not cost or value. clearCostValue :: UIState -> UIState clearCostValue ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{rsOpts=ropts}}}} = - ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{rsOpts=ropts{value_ = plog "clearing value mode" Nothing}}}}} + ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{rsOpts=ropts{cost_ = NoCost, value_ = Nothing}}}}} -- | Toggle between showing the primary amounts or costs. toggleCost :: UIState -> UIState