summaryrefslogtreecommitdiffhomepage
path: root/Replay.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-26 16:15:43 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-26 16:18:01 -0400
commit52f9c68869fa8956db55980f0b36ba817f825ffb (patch)
treeb288b73ee5766a0048b1e2d593a0d0ec130044c0 /Replay.hs
parent62f7653e39e95d3e9cd308810e487e3cdee84d52 (diff)
downloaddebug-me-52f9c68869fa8956db55980f0b36ba817f825ffb.tar.gz
include elapsedTime in Activity
Time is relative, so the debug-me proof chain doesn't prove when things happened, but it's still useful to have some idea of how long things took to happen. This makes --replay work with logs gotten by --download. Log still includes loggedTimestamp. This is a bit redundant, and is unused now, but it's useful for log files to record when messages were received. This commit was sponsored by Riku Voipio.
Diffstat (limited to 'Replay.hs')
-rw-r--r--Replay.hs21
1 files changed, 9 insertions, 12 deletions
diff --git a/Replay.hs b/Replay.hs
index 1993ce3..8d2e3ae 100644
--- a/Replay.hs
+++ b/Replay.hs
@@ -9,22 +9,19 @@ import System.IO
import Control.Concurrent.Thread.Delay
replay :: ReplayOpts -> IO ()
-replay opts = go Nothing =<< streamLog (replayLogFile opts)
+replay opts = go =<< streamLog (replayLogFile opts)
where
- go _ [] = return ()
- go prevts (Right l:ls) = do
- case prevts of
- Nothing -> return ()
- Just t ->
- let s = loggedTimestamp l - t
- ms = s * 1000000
- in delay (ceiling ms)
-
+ go [] = return ()
+ go (Right l:ls) = do
case loggedMessage l of
User (ActivityMessage a) -> do
+ maybe (return ()) realisticDelay (elapsedTime a)
B.hPut stdout $ val $ seenData $ activity a
hFlush stdout
User (ControlMessage _) -> return ()
Developer _ -> return ()
- go (Just $ loggedTimestamp l) ls
- go _ (Left l:_) = error $ "Failed to parse a line of the log: " ++ l
+ go ls
+ go (Left l:_) = error $ "Failed to parse a line of the log: " ++ l
+
+realisticDelay :: ElapsedTime -> IO ()
+realisticDelay (ElapsedTime n) = delay $ ceiling $ n * 1000000