From 70c697d5f753129d51da1043d4f8142d3dcfdcb4 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Mon, 12 Dec 2016 18:07:54 +0700 Subject: [PATCH] Debug++ --- src/ATrade/Broker/Client.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ATrade/Broker/Client.hs b/src/ATrade/Broker/Client.hs index af14b3d..f58a101 100644 --- a/src/ATrade/Broker/Client.hs +++ b/src/ATrade/Broker/Client.hs @@ -43,11 +43,14 @@ data BrokerClientHandle = BrokerClientHandle { brokerClientThread :: Context -> T.Text -> MVar BrokerServerRequest -> MVar BrokerServerResponse -> MVar () -> MVar () -> IO () brokerClientThread ctx ep cmd resp comp killMv = finally brokerClientThread' cleanup where - cleanup = putMVar comp () - brokerClientThread' = whileM_ (isNothing <$> tryReadMVar killMv) $ handle - (\e -> do + cleanup = infoM "Broker.Client" "Quitting broker client thread" >> putMVar comp () + brokerClientThread' = whileM_ (isNothing <$> tryReadMVar killMv) $ do + debugM "Broker.Client" "Starting event loop" + handle (\e -> do warningM "Broker.Client" $ "Broker client: exception: " ++ (show (e :: SomeException)) ++ "; isZMQ: " ++ show (isZMQError e) - unless (isZMQError e) $ throwIO e) $ withSocket ctx Req (\sock -> do + unless (isZMQError e) $ do + debugM "Broker.Client" "Rethrowing exception" + throwIO e) $ withSocket ctx Req (\sock -> do connect sock $ T.unpack ep whileM_ (isNothing <$> tryReadMVar killMv) $ do request <- takeMVar cmd