Source

imagepaste / src / Log.hs

Full commit
{-# LANGUAGE CPP #-}
module Log (msgDebug,
            msgInfo,
            msgError,
            dumpString) where

import System.IO

msgDebug :: String -> IO ()
#ifdef IMAGEPASTE_DEBUG
msgDebug msg = putStrLn $ "DEBUG: " ++ msg
#else
msgDebug _ = return ()
#endif

msgError :: String -> IO ()
msgError = hPutStrLn stderr

msgInfo :: String -> IO ()
msgInfo = putStrLn

dumpString :: FilePath -> String -> IO ()
#ifdef IMAGEPASTE_DEBUG
dumpString file str = do
  h1 <- openBinaryFile file WriteMode
  hPutStr h1 str
  hClose h1
#else
dumpString _ _ = return ()
#endif