summaryrefslogtreecommitdiffhomepage
path: root/Graphviz.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-19 17:30:32 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-19 17:45:14 -0400
commit6f7cf857b408401abdc4477c888495b4f13162c7 (patch)
tree5b746c171df6e68864b2bbaacf2e833587832367 /Graphviz.hs
parent951d165bc27b9397174af1d826366e39cdbd53dd (diff)
downloaddebug-me-6f7cf857b408401abdc4477c888495b4f13162c7.tar.gz
reorganized message types
Make Control messages be out-of-band async messages, without a pointer to a previous message. And then followed the type change through the code for hours.. This commit was sponsored by Nick Daly on Patreon.
Diffstat (limited to 'Graphviz.hs')
-rw-r--r--Graphviz.hs60
1 files changed, 34 insertions, 26 deletions
diff --git a/Graphviz.hs b/Graphviz.hs
index b85821c..59f3bf9 100644
--- a/Graphviz.hs
+++ b/Graphviz.hs
@@ -7,7 +7,7 @@ import Hash
import CmdLine
import Log
-import Data.Char
+import Data.Char hiding (Control)
import Data.Monoid
import Data.GraphViz
import Data.GraphViz.Attributes.Complete
@@ -30,42 +30,48 @@ graphviz opts = do
createImage :: PrintDotRepr dg n => FilePath -> GraphvizOutput -> dg n -> IO FilePath
createImage f o g = Data.GraphViz.addExtension (runGraphvizCommand Dot g) o f
-genGraph :: GraphvizOpts -> [ActivityLog] -> G.DotGraph T.Text
+genGraph :: GraphvizOpts -> [Log] -> G.DotGraph T.Text
genGraph opts ls = digraph (Str "debug-me") $ do
nodeAttrs [style filled]
forM_ ls $
- showactivity [ xcolor Green ]
+ showlog [ xcolor Green ]
where
- showactivity s l = case loggedActivity l of
- ActivitySeen a -> do
+ showlog s l = case (loggedMessage l, loggedHash l) of
+ (User (ActivityMessage a), Just h) -> do
node (display h) $ s ++
[ textLabel $ prettyDisplay $ activity a
, shape BoxShape
]
- case activity a of
- Rejected ar -> do
- let hr = hash ar
- let rejstyle =
- [ xcolor Red
- , Style [dashed, filled]
- ]
- showactivity rejstyle $
- ActivityLog
- { loggedActivity = ActivityEntered ar
- , loggedHash = hr
- , loggedTimestamp = loggedTimestamp l
- }
- link hr h rejstyle
- _ -> return ()
linkprev s a h
- ActivityEntered a -> do
+ (Developer (ActivityMessage a), Just h) -> do
node (display h) $ s ++
[ textLabel $ prettyDisplay $ activity a
, shape Circle
]
linkprev s a h
- where
- h = loggedHash l
+ (User (ControlMessage c), Nothing) -> showcontrol c l
+ (Developer (ControlMessage c), Nothing) -> showcontrol c l
+ _ -> return ()
+
+ showcontrol (Control (Rejected ar) _) l = do
+ let hr = hash ar
+ let rejstyle =
+ [ xcolor Red
+ , Style [dashed, filled]
+ ]
+ let nodename = display $ "Rejected " <> display hr
+ node nodename $ rejstyle ++
+ [ textLabel "Rejected"
+ , shape BoxShape
+ ]
+ showlog rejstyle $ Log
+ { loggedMessage = Developer (ActivityMessage ar)
+ , loggedHash = Just hr
+ , loggedTimestamp = loggedTimestamp l
+ }
+ edge nodename (display hr) rejstyle
+ showcontrol _ _ = return ()
+
linkprev s a h = case prevActivity a of
Nothing -> return ()
Just p -> link p h s
@@ -114,6 +120,8 @@ instance Display Entered where
| B.null (val $ echoData v) = display $ enteredData v
| otherwise = "[" <> display (echoData v) <> "] " <> display (enteredData v)
-instance Display a => Display (Proto a) where
- display (Proto a) = display a
- display (Rejected a) = "Rejected: " <> display (activity a)
+instance Display Control where
+ display = display . control
+
+instance Display ControlAction where
+ display = T.pack . show