diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-01-16 18:41:23 +0000 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-01-16 18:42:30 +0000 |
commit | a049cbb8818046e9b73cc39e6155a6978ef7cef0 (patch) | |
tree | 48f0bfb43a3babc47f252159e5dfb1d0187515ed /Bustle | |
parent | df32c683b917e5f8039fb00b2a6e1099dde799a6 (diff) |
Include timestamps in live logs
Diffstat (limited to 'Bustle')
-rw-r--r-- | Bustle/Monitor.hs | 13 | ||||
-rw-r--r-- | Bustle/UI/Recorder.hs | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/Bustle/Monitor.hs b/Bustle/Monitor.hs index 2b5845e..d1e5c1d 100644 --- a/Bustle/Monitor.hs +++ b/Bustle/Monitor.hs @@ -28,6 +28,8 @@ import System.Glib.GObject import System.Glib.GError import System.Glib.Signals +import Bustle.Types (Microseconds) + -- Gtk2HS boilerplate newtype Monitor = Monitor { unMonitor :: ForeignPtr Monitor } deriving (Eq, Ord) @@ -81,18 +83,21 @@ monitorStop :: Monitor monitorStop monitor = do withForeignPtr (unMonitor monitor) bustle_pcap_monitor_stop -messageLoggedHandler :: (BS.ByteString -> IO ()) +messageLoggedHandler :: (Microseconds -> BS.ByteString -> IO ()) -> a -> Ptr () -> CInt + -> CLong + -> CLong -> Ptr CChar -> CUInt -> IO () -messageLoggedHandler user _obj _messageObject _isIncoming blob blobLength = do +messageLoggedHandler user _obj _messageObject _isIncoming sec usec blob blobLength = do blobBS <- BS.packCStringLen (blob, fromIntegral blobLength) - failOnGError $ user blobBS + let µsec = fromIntegral sec * (10 ^ (6 :: Int)) + fromIntegral usec + failOnGError $ user µsec blobBS -monitorMessageLogged :: Signal Monitor (BS.ByteString -> IO ()) +monitorMessageLogged :: Signal Monitor (Microseconds -> BS.ByteString -> IO ()) monitorMessageLogged = Signal $ \after_ obj user -> connectGeneric "message-logged" after_ obj $ messageLoggedHandler user diff --git a/Bustle/UI/Recorder.hs b/Bustle/UI/Recorder.hs index 161ca88..bab2038 100644 --- a/Bustle/UI/Recorder.hs +++ b/Bustle/UI/Recorder.hs @@ -47,10 +47,10 @@ recorderRun filename mwindow incoming finished = handleGError newFailed $ do -- FIXME: this is stupid. If we have to manually combine the outputs, it's -- basically just more state. rendererResultRef <- newMVar mempty - let updateLabel body = do + let updateLabel µs body = do -- of course, modifyMVar and runStateT have their tuples back to front. m <- modifyMVar loaderStateRef $ \s -> do - (m, s') <- runStateT (convert 0 body) s + (m, s') <- runStateT (convert µs body) s return (s', m) case m of |