summaryrefslogtreecommitdiffhomepage
path: root/debug-me.hs
diff options
context:
space:
mode:
Diffstat (limited to 'debug-me.hs')
-rw-r--r--debug-me.hs26
1 files changed, 3 insertions, 23 deletions
diff --git a/debug-me.hs b/debug-me.hs
index 058e23a..0b51878 100644
--- a/debug-me.hs
+++ b/debug-me.hs
@@ -6,7 +6,9 @@ import Types
import Hash
import Pty
import CmdLine
+import Log
import Graphviz
+import Replay
import Control.Concurrent
import Control.Concurrent.Async
@@ -15,11 +17,9 @@ import System.IO
import System.Process
import System.Exit
import qualified Data.ByteString as B
-import qualified Data.ByteString.Lazy as L
import Data.List
import Data.List.NonEmpty (NonEmpty(..), toList)
import Data.Monoid
-import Data.Aeson
import Data.Time.Clock.POSIX
main :: IO ()
@@ -28,6 +28,7 @@ main = do
case mode c of
Test -> test
Graphviz g -> graphviz g
+ Replay r -> replay r
test :: IO ()
test = do
@@ -214,27 +215,6 @@ user startmsg p ichan ochan = withLogger "debug-me.log" $ \logger -> do
data Backlog = Backlog (NonEmpty ActivityLog)
deriving (Show)
-type Logger = SomeActivity -> IO ()
-
-withLogger :: FilePath -> (Logger -> IO a) -> IO a
-withLogger logfile a = withFile logfile WriteMode (a . mkLogger)
-
-mkLogger :: Handle -> Logger
-mkLogger h a = do
- l <- mkActivityLog a <$> getPOSIXTime
- L.hPut h (encode l)
- hPutStr h "\n"
- hFlush h
-
-mkActivityLog :: SomeActivity -> POSIXTime -> ActivityLog
-mkActivityLog a now = ActivityLog
- { loggedActivity = a
- , loggedHash = case a of
- ActivitySeen s -> hash s
- ActivityEntered e -> hash e
- , loggedTimestamp = now
- }
-
-- | Forward things written to the Pty out the TChan.
sendPtyOutput :: Pty -> TChan (Activity Seen) -> TVar Backlog -> Logger -> IO ()
sendPtyOutput p ochan backlog logger = go