aboutsummaryrefslogtreecommitdiff
path: root/CabalHelper/Compiletime/Log.hs
diff options
context:
space:
mode:
Diffstat (limited to 'CabalHelper/Compiletime/Log.hs')
-rw-r--r--CabalHelper/Compiletime/Log.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/CabalHelper/Compiletime/Log.hs b/CabalHelper/Compiletime/Log.hs
new file mode 100644
index 0000000..e4033f1
--- /dev/null
+++ b/CabalHelper/Compiletime/Log.hs
@@ -0,0 +1,21 @@
+module CabalHelper.Compiletime.Log where
+
+import Control.Monad
+import Control.Monad.IO.Class
+import Control.Exception as E
+import Data.String
+import System.IO
+import Prelude
+
+import CabalHelper.Shared.Types
+
+vLog :: MonadIO m => Options -> String -> m ()
+vLog Options { verbose = True } msg =
+ liftIO $ hPutStrLn stderr msg
+vLog _ _ = return ()
+
+logSomeError :: Options -> String -> IO (Maybe a) -> IO (Maybe a)
+logSomeError opts label a = do
+ a `E.catch` \se@(SomeException _) -> do
+ vLog opts $ label ++ ": " ++ show se
+ return Nothing