diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-22 11:41:54 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-22 11:41:54 -0400 |
commit | 362d3a437c16c10d221caeac21e9f685d7ddf3e6 (patch) | |
tree | 89e8ca2a63bebd6355c4d6b163592e538ba2eced /Log.hs | |
parent | db4e4c47898c0bb3dab27ee82ca563e37aaf62ea (diff) | |
download | debug-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.hs | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -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 |