summaryrefslogtreecommitdiffhomepage
path: root/Log.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-22 11:41:54 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-22 11:41:54 -0400
commit362d3a437c16c10d221caeac21e9f685d7ddf3e6 (patch)
tree89e8ca2a63bebd6355c4d6b163592e538ba2eced /Log.hs
parentdb4e4c47898c0bb3dab27ee82ca563e37aaf62ea (diff)
downloaddebug-me-362d3a437c16c10d221caeac21e9f685d7ddf3e6.tar.gz
stream the log
avoid processing it in memory, and allow parse errors at end to not prevent displaying part of it
Diffstat (limited to 'Log.hs')
-rw-r--r--Log.hs11
1 files changed, 4 insertions, 7 deletions
diff --git a/Log.hs b/Log.hs
index 50c506d..6c45074 100644
--- a/Log.hs
+++ b/Log.hs
@@ -87,10 +87,7 @@ parseLog = map eitherDecode'
. filter (not . L.null)
. L.split (fromIntegral (ord '\n'))
--- | Throws exception on unparsable log.
-loadLog :: FilePath -> IO [Log]
-loadLog f = do
- parsed <- parseLog <$> L.readFile f
- case lefts parsed of
- [] -> return (rights parsed)
- errs -> error $ unlines errs
+-- | Streams a log without loading it all into memory.
+-- When lines cannot be parsed, they will be Left.
+streamLog :: FilePath -> IO [Either String Log]
+streamLog f = parseLog <$> L.readFile f