ADD logging for device init

This commit is contained in:
Nathan Dwarshuis 2023-01-01 22:03:17 -05:00
parent 2948610785
commit cc094bb071
1 changed files with 7 additions and 1 deletions

View File

@ -78,6 +78,7 @@ startAdapter is cs cb cl = do
ot <- getBtObjectTree cl
state <- newMVar emptyState
let dpy = displayIcon cb (iconFormatter is cs) state
-- TODO if this fails it won't be logged
forM_ (findAdapter ot) $ \adapter -> do
-- set up adapter
initAdapter state adapter cl
@ -227,9 +228,12 @@ initAdapter
-> m ()
initAdapter state adapter client = do
reply <- callGetPowered adapter client
logInfo $ "initializing adapter at path " <> adapter_
-- TODO this could fail if the variant is something weird; the only
-- indication I will get is "NA"
putPowered state $ fromSingletonVariant reply
where
adapter_ = displayWrapQuote $ displayObjectPath adapter
matchBTProperty
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
@ -310,7 +314,9 @@ addAndInitDevice
addAndInitDevice state dpy device client = do
res <- addDeviceListener state dpy device client
case res of
Just handler -> initDevice state handler device client
Just handler -> do
logInfo $ "initializing device at path " <> device_
initDevice state handler device client
Nothing -> logError $ "could not initialize device at path " <> device_
where
device_ = displayWrapQuote $ displayObjectPath device