imp: ui: debug log startup args, debug level, initial screen stack

This commit is contained in:
Simon Michael 2022-11-07 14:52:42 -10:00
parent da569e51e1
commit 1a526b82c9

View File

@ -1,5 +1,3 @@
-- TODO: brick 1 support
-- https://hackage.haskell.org/package/brick-1.0/changelog
{-|
hledger-ui - a hledger add-on providing a curses-style interface.
Copyright (c) 2007-2015 Simon Michael <simon@joyful.com>
@ -37,7 +35,7 @@ import Hledger.UI.Theme
import Hledger.UI.UIOptions
import Hledger.UI.UITypes
import Hledger.UI.UIState (uiState, getDepth)
import Hledger.UI.UIUtils (dbguiEv)
import Hledger.UI.UIUtils (dbguiEv, showScreenStack, showScreenSelection)
import Hledger.UI.MenuScreen
import Hledger.UI.AccountsScreen
import Hledger.UI.BalancesheetScreen
@ -58,6 +56,10 @@ writeChan = BC.writeBChan
main :: IO ()
main = withProgName "hledger-ui.log" $ do -- force Hledger.Utils.Debug.* to log to hledger-ui.log
traceLogAtIO 1 "\n\n\n\n==== hledger-ui start"
dbg1IO "args" progArgs
dbg1IO "debugLevel" debugLevel
opts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=iopts,rawopts_=rawopts}} <- getHledgerUIOpts
-- when (debug_ $ cliopts_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts)
@ -142,7 +144,9 @@ runBrickUi uopts0@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=r
-- if an account query has been provided at startup.
-- Whichever it is, we also set up a stack of previous screens,
-- as if you had navigated down to it from the top.
(prevscrs, currscr) = case (uoRegister uopts, hasbsaccts, hasacctquery) of
(prevscrs, currscr) =
dbg1With (showScreenStack "initial" showScreenSelection . uncurry2 (uiState defuiopts nulljournal)) $
case (uoRegister uopts, hasbsaccts, hasacctquery) of
-- With --register=ACCT, the initial screen stack is:
-- 1. menu screen, with ACCTSSCR selected
@ -210,8 +214,6 @@ runBrickUi uopts0@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=r
setMode (outputIface v) Mouse True
return v
traceLogAtIO 1 "\n\n==== hledger-ui start"
if not (uoWatch uopts)
then do
vty <- makevty