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