diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-18 14:18:16 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-18 14:20:09 -0400 |
commit | 9102a47c6c68039a288a6ee8f43fe14b034ce356 (patch) | |
tree | e88eefe101db6381625518c68c7d8ed9e1fe3bac /Replay.hs | |
parent | ccdb5a3c6a28cc6745d337bdb67e62d70216ef7e (diff) | |
download | debug-me-9102a47c6c68039a288a6ee8f43fe14b034ce356.tar.gz |
add --replay option
This commit was sponsored by Ole-Morten Duesund on Patreon.
Diffstat (limited to 'Replay.hs')
-rw-r--r-- | Replay.hs | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -3,10 +3,29 @@ module Replay where import Types import Log import CmdLine +import Session + +import qualified Data.ByteString as B +import System.IO +import Control.Concurrent.Thread.Delay replay :: ReplayOpts -> IO () -replay opts = go =<< loadLog (replayLogFile opts) +replay opts = go Nothing =<< loadLog (replayLogFile opts) where - go [] = return () - go (l:ls) = do - go ls + go _ [] = sessionDone + go prevts (l:ls) = do + case prevts of + Nothing -> return () + Just t -> + let s = loggedTimestamp l - t + ms = s * 1000000 + in delay (ceiling ms) + + case loggedActivity l of + ActivityEntered {} -> return () + ActivitySeen a -> case activity a of + Rejected {} -> return () + Proto s -> do + B.hPut stdout (val (seenData s)) + hFlush stdout + go (Just $ loggedTimestamp l) ls |