@@ -99,7 +99,7 @@ import Control.Distributed.Process.Internal.Types
9999 , LocalProcessId(..)
100100 , ProcessId(..)
101101 , LocalNode(..)
102− , Tracer
102+ , Tracer(InactiveTracer)
103103 , LocalNodeState(..)
104104 , LocalProcess(..)
105105 , LocalProcessState(..)
@@ -144,9 +144,9 @@ import Control.Distributed.Process.Internal.Types
144144 , ImplicitReconnect(WithImplicitReconnect, NoImplicitReconnect)
145145 )
146146import Control.Distributed.Process.Internal.Trace
147− ( trace
147+ ( TraceArg(..)
148148 , traceFormat
149− , defaultTracer
149+ , startTracing
150150 , stopTracer
151151 )
152152import Control.Distributed.Process.Serializable (Serializable)
@@ -200,18 +200,18 @@ createBareLocalNode endPoint rtable = do
200200 , _localPidUnique = unq
201201 , _localConnections = Map.empty
202202 }
203− tracer <- defaultTracer
204203 ctrlChan <- newChan
205204 let node = LocalNode { localNodeId = NodeId $ NT.address endPoint
206205 , localEndPoint = endPoint
207206 , localState = state
208207 , localCtrlChan = ctrlChan
209− , localTracer = tracer
208+ , localTracer = InactiveTracer
210209 , remoteTable = rtable
211210 }
212− void . forkIO $ runNodeController node
213− void . forkIO $ handleIncomingMessages node
214− return node
211+ tracedNode <- startTracing node
212+ void . forkIO $ runNodeController tracedNode
213+ void . forkIO $ handleIncomingMessages tracedNode
214+ return tracedNode
215215
216216-- | Start and register the service processes on a node
217217-- (for now, this is only the logger)
@@ -225,6 +225,10 @@ startServiceProcesses node = do
225225 [ match $ \((time, pid, string) ::(String, ProcessId, String)) -> do
226226 liftIO . hPutStrLn stderr $ time ++ " " ++ show pid ++ ": " ++ string
227227 loop
228+ , match $ \((time, string) :: (String, String)) -> do
229+ -- this is a 'trace' message from the local node tracer
230+ liftIO . hPutStrLn stderr $ time ++ " [trace] " ++ string
231+ loop
228232 , match $ \(ch :: SendPort ()) -> -- a shutdown request
229233 sendChan ch ()
230234 ]
@@ -431,15 +435,18 @@ handleIncomingMessages node = go initConnectionState
431435 $ st
432436 )
433437 NT.ErrorEvent (NT.TransportError NT.EventEndPointFailed str) ->
434− fail $ "Cloud Haskell fatal error: end point failed: " ++ str
438+ fatal $ "Cloud Haskell fatal error: end point failed: " ++ str
435439 NT.ErrorEvent (NT.TransportError NT.EventTransportFailed str) ->
436− fail $ "Cloud Haskell fatal error: transport failed: " ++ str
440+ fatal $ "Cloud Haskell fatal error: transport failed: " ++ str
437441 NT.EndPointClosed ->
438− return ()
442+ stopTracer (localTracer node) >> return ()
439443 NT.ReceivedMulticast _ _ ->
440444 -- If we received a multicast message, something went horribly wrong
441445 -- and we just give up
442− fail "Cloud Haskell fatal error: received unexpected multicast"
446+ fatal "Cloud Haskell fatal error: received unexpected multicast"
447+
448+ fatal :: String -> IO ()
449+ fatal msg = stopTracer (localTracer node) >> fail msg
443450
444451 invalidRequest :: NT.ConnectionId -> ConnectionState -> IO ()
445452 invalidRequest cid st = do
@@ -447,7 +454,8 @@ handleIncomingMessages node = go initConnectionState
447454 -- node. That is, we should report the remote node as having died, and we
448455 -- should close incoming connections (this requires a Transport layer
449456 -- extension).
450− traceEventFmtIO node "" ["[network] invalid request: ", (show cid)]
457+ traceEventFmtIO node "" [(TraceStr "[network] invalid request: "),
458+ (Trace cid)]
451459 go ( incomingAt cid ^= Nothing
452460 $ st
453461 )
@@ -510,21 +518,17 @@ traceNotifyDied node ident reason =
510518 case reason of
511519 DiedNormal -> return ()
512520 _ -> traceNcEventFmt node " "
513− ["[node-controller]", (show ident), (show reason)]
521+ [(TraceStr "[node-controller]"),
522+ (Trace ident),
523+ (Trace reason)]
514524
515−traceNcEvent :: LocalNode -> String -> NC ()
516−traceNcEvent node msg = liftIO $ traceEventIO node msg
517−
518−traceNcEventFmt :: LocalNode -> String -> [String] -> NC ()
525+traceNcEventFmt :: LocalNode -> String -> [TraceArg] -> NC ()
519526traceNcEventFmt node fmt args =
520527 liftIO $ traceEventFmtIO node fmt args
521528
522−traceEventIO :: LocalNode -> String -> IO ()
523−traceEventIO node msg = withLocalTracer node $ \t -> trace t msg
524−
525529traceEventFmtIO :: LocalNode
526530 -> String
527− -> [String]
531+ -> [TraceArg]
528532 -> IO ()
529533traceEventFmtIO node fmt args =
530534 withLocalTracer node $ \t -> traceFormat t fmt args