]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
agitprop log messages
authorFrank Doepper <[email protected]>
Fri, 6 Jul 2018 16:20:35 +0000 (18:20 +0200)
committerFrank Doepper <[email protected]>
Fri, 6 Jul 2018 16:20:35 +0000 (18:20 +0200)
agitprop.hs

index 9dd7213c6a2c3afccf4171a8ea1109a5e62d4133..480307a9e5bcd11df2e0cd62bff2a4cc5c9e9d0a 100644 (file)
@@ -53,21 +53,24 @@ main = do
              [CloseWrite, MoveIn]
              (inputFile args)
              (handleEvent publishOneMsg (suffix args) (inputFile args))
-         hr $ "watching " ++ (inputFile args)
+         hr $ "BEGIN watching " ++ (inputFile args)
          _ <- forever $ threadDelay 1000000
          removeWatch wd
+         hr $ "END watching " ++ (inputFile args)
        else do
-         hr $ "sending " ++ (inputFile args)
+         hr $ "BEGIN sending"
          messageFile <- BL.readFile (inputFile args)
          if (lineMode args)
            then mapM_ (publishOneMsg Nothing) (BL.lines messageFile)
-           else publishOneMsg (Just (inputFile args)) messageFile)
+           else publishOneMsg (Just (inputFile args)) messageFile
+         hr "END sending")
     (\exception -> printparam' "exception" $ show (exception :: X.SomeException))
   -- all done. wait and close.
   if (confirm args)
-    then waitForConfirms chan >>= return . show >> return ()
+    then waitForConfirms chan >>= (printparam' "confirmed") . show
     else return ()
   closeConnection conn
+  hr "connection closed"
 
 -- | The handler for publisher confirms
 confirmCallback :: (Word64, Bool, AckType) -> IO ()
@@ -102,7 +105,7 @@ handleFile f s@(_:_) x =
     else return ()
 handleFile f [] x =
   X.catch
-    (hr ("sending " ++ x) >> BL.readFile x >>= f (Just x))
+    (BL.readFile x >>= f (Just x))
     (\exception ->
        printparam' "exception in handleFile" $
        show (exception :: X.SomeException))
@@ -110,6 +113,7 @@ handleFile f [] x =
 -- | Publish one message with our settings
 publishOneMsg' :: Channel -> Args -> Maybe String -> BL.ByteString -> IO ()
 publishOneMsg' c a fn f = do
+  printparam "sending" fn
   (mtype, mencoding) <-
     if (magic a) && isJust fn
       then do