]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
suppress empty loglines again
authorFrank Doepper <[email protected]>
Sat, 7 Dec 2019 21:05:38 +0000 (22:05 +0100)
committerFrank Doepper <[email protected]>
Sat, 7 Dec 2019 21:05:38 +0000 (22:05 +0100)
Network/AMQP/Utils/Connection.hs
Network/AMQP/Utils/Helpers.hs

index 327878c04a9ee42d7fb08900e958064eb926e912..c32f92aa5cfbc909b9d4c5403b261f7976106f24 100644 (file)
@@ -21,7 +21,7 @@ connect args = do
   printparam "port" $ port args
   printparam "vhost" $ vHost args
   printparam "connection_name" $ connectionName args
-  printparam "connect timeout" $ (show (connect_timeout args)) ++ "s"
+  printparam "connect timeout" $ [show (connect_timeout args), "s"]
   globalCertificateStore <- getSystemCertificateStore
   let myTLS =
         N.TLSSettings
index 270dadd8e8e605fe037cf377e0ab58513b5c0490..4dd8bf6eb66a927db185ed78c99336b021eadc88 100644 (file)
@@ -23,27 +23,37 @@ class (Show a) =>
   where
   flexprint :: a -> IO ()
   flexprint = (hPutStrLn stderr) . show
+  empty :: a -> Bool
+  empty _ = False
   printparam :: String -> a -> IO ()
-  printparam label x = do
-    mapM_ (hPutStr stderr) [" --- ", label, ": "]
-    flexprint x
-    hFlush stderr
+  printparam label x =
+    if empty x
+      then return ()
+      else do
+        mapM_ (hPutStr stderr) [" --- ", label, ": "]
+        flexprint x
+        hFlush stderr
 
 instance (Flexprint a) => Flexprint (Maybe a) where
+  empty = isNothing
   printparam _ Nothing = return ()
   printparam x (Just y) = printparam x y
 
 instance Flexprint String where
   flexprint = hPutStrLn stderr
+  empty = null
 
 instance Flexprint [String] where
   flexprint = flexprint . unwords
+  empty = null
 
 instance Flexprint T.Text where
   flexprint = flexprint . T.unpack
+  empty = T.null
 
 instance Flexprint BL.ByteString where
   flexprint x = hPutStrLn stderr "" >> BL.hPut stderr x >> hPutStrLn stderr ""
+  empty = BL.null
 
 instance Flexprint Bool
 
don't click here