summaryrefslogtreecommitdiffhomepage
path: root/Graphviz.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-18 13:54:16 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-18 14:04:42 -0400
commitccdb5a3c6a28cc6745d337bdb67e62d70216ef7e (patch)
tree1a63fac950bf66bba59812d8e2f6b66aa1a05c63 /Graphviz.hs
parent88a9ce01d153ad609aa02084de0a93448c29cba4 (diff)
downloaddebug-me-ccdb5a3c6a28cc6745d337bdb67e62d70216ef7e.tar.gz
refactor out Log
Diffstat (limited to 'Graphviz.hs')
-rw-r--r--Graphviz.hs24
1 files changed, 5 insertions, 19 deletions
diff --git a/Graphviz.hs b/Graphviz.hs
index c6ce8a9..b85821c 100644
--- a/Graphviz.hs
+++ b/Graphviz.hs
@@ -5,11 +5,9 @@ module Graphviz (graphviz) where
import Types
import Hash
import CmdLine
+import Log
-import Data.Aeson
import Data.Char
-import Data.Word
-import Data.Either
import Data.Monoid
import Data.GraphViz
import Data.GraphViz.Attributes.Complete
@@ -24,22 +22,10 @@ import Data.Text.Encoding.Error
graphviz :: GraphvizOpts -> IO ()
graphviz opts = do
- parsed <- parseLog <$> L.readFile (graphvizLogFile opts)
- case lefts parsed of
- [] -> do
- let g = genGraph opts (rights parsed)
- f <- createImage (graphvizLogFile opts) Png g
- putStrLn ("Generated " ++ f)
- errs -> error $ unlines errs
-
-parseLog :: L.ByteString -> [Either String ActivityLog]
-parseLog = map eitherDecode'
- . filter (not . L.null)
- . L.split nl
-
-
-nl :: Word8
-nl = fromIntegral (ord '\n')
+ l <- loadLog (graphvizLogFile opts)
+ let g = genGraph opts l
+ f <- createImage (graphvizLogFile opts) Png g
+ putStrLn ("Generated " ++ f)
createImage :: PrintDotRepr dg n => FilePath -> GraphvizOutput -> dg n -> IO FilePath
createImage f o g = Data.GraphViz.addExtension (runGraphvizCommand Dot g) o f