packages feed

micrologger 0.3.1.0 → 0.3.1.1

raw patch · 2 files changed

+3/−3 lines, 2 files

Files

micrologger.cabal view
@@ -1,5 +1,5 @@ name:                micrologger-version:             0.3.1.0+version:             0.3.1.1 synopsis:            A super simple logging module. Only for use for very simple projects. description:         A super simple logging module. Only for use for very simple projects. homepage:            https://github.com/savannidgerinel/micrologger#readme
src/LuminescentDreams/Logger.hs view
@@ -17,7 +17,7 @@ import           LuminescentDreams.Logger.Standard    as X  import qualified Data.Text.Lazy                       as T-import           System.IO                            (IOMode(..), hPutStrLn, withFile)+import           System.IO                            (IOMode(..), hPutStrLn, hFlush, withFile)  {- | Ordinary configurations for a file-based logger. -} data LogConfig = LogConfig { path :: FilePath@@ -29,4 +29,4 @@ {- | Run an IO action with a log safely available. Logs will be properly closed in the case of an exception. Logging is meant to happen to a file, specified in LogConfig, so this may not be suitable if you want to log to a different resource. -} withLogger :: LogConfig -> (Logger -> IO a) -> IO a withLogger LogConfig{..} act =-  withFile path AppendMode $ \h -> act (Logger (hPutStrLn h . T.unpack) level)+  withFile path AppendMode $ \h -> act (Logger (\m -> hPutStrLn h (T.unpack m) >> hFlush h) level)