Skip to content

Commit f8150f9

Browse files
committed
ouroboros-network-framework:logging
1 parent c00a151 commit f8150f9

File tree

6 files changed

+9
-236
lines changed

6 files changed

+9
-236
lines changed

cabal.project

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ source-repository-package
3232
tag: 9a45b2c632a0bba816f1c07eb8601f1c7b675ab7
3333
--sha256: 14yg2p4b8j6rrg7d479095iir95nh5jhfawf48j8kjj90h3bh390
3434

35-
-- `ouroboros-network/ouroboros-network:traces` branch "fmaste/ouroboros-network".
35+
-- `ouroboros-network/ouroboros-network-framework:logging` branch "fmaste/ouroboros-network-framework".
3636
source-repository-package
3737
type: git
3838
location: https://github.com/IntersectMBO/ouroboros-network.git
39-
subdir: ouroboros-network
40-
tag: 7dcbfab966e55b6218f47af5f3b1c70ff23ecec3
41-
--sha256: 09m1l0vi3z83brz2hakliqzifpgcg1saw38p0jspv1q4s02hkvf6
39+
subdir: ouroboros-network-framework
40+
tag: 45a393ab7e18b0e367563d221b172efedbdd857b
41+
--sha256: 173vgkhg6idb400sqn3d7prjbpx6z1gc7rnspsacyca4j1aqsi08
4242

4343
packages:
4444
cardano-node

cardano-node/cardano-node.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ library
196196
, ouroboros-network:{ouroboros-network, cardano-diffusion, orphan-instances} ^>= 0.22.3
197197
, ouroboros-network:logging
198198
, ouroboros-network-framework ^>= 0.19.2
199+
, ouroboros-network-framework:logging
199200
, ouroboros-network-protocols ^>= 0.15
200201
, prettyprinter
201202
, prettyprinter-ansi-terminal

cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import Ouroboros.Network.BlockFetch.ClientState (TraceLabelPeer (..))
6565
import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
6666
import Ouroboros.Network.BlockFetch.Decision
6767
import Ouroboros.Network.BlockFetch.Decision.Trace (TraceDecisionEvent (..))
68-
import Ouroboros.Network.ConnectionId (ConnectionId (..))
68+
import Ouroboros.Network.Logging.Framework ()
6969
import Ouroboros.Network.SizeInBytes (SizeInBytes (..))
7070
import Ouroboros.Network.Logging ()
7171
import Ouroboros.Network.TxSubmission.Inbound hiding (txId)
@@ -85,15 +85,6 @@ import Data.Word (Word32, Word64)
8585
import Network.TypedProtocol.Core
8686

8787

88-
instance (LogFormatting adr, Show adr) => LogFormatting (ConnectionId adr) where
89-
forMachine _dtal (ConnectionId local' remote) =
90-
mconcat [ "connectionId" .= String (showT local'
91-
<> " "
92-
<> showT remote)
93-
]
94-
forHuman (ConnectionId local' remote) =
95-
"ConnectionId " <> showT local' <> " " <> showT remote
96-
9788
--------------------------------------------------------------------------------
9889
-- TraceLabelCreds peer a
9990
--------------------------------------------------------------------------------

cardano-node/src/Cardano/Node/Tracing/Tracers/Diffusion.hs

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -14,87 +14,9 @@
1414
module Cardano.Node.Tracing.Tracers.Diffusion
1515
() where
1616

17-
18-
import Cardano.Logging
1917
import Cardano.Node.Configuration.TopologyP2P ()
2018

2119
import Ouroboros.Network.Logging ()
22-
import qualified Ouroboros.Network.Protocol.Handshake.Type as HS
20+
import Ouroboros.Network.Logging.Framework ()
2321
import Network.Mux.Logging ()
24-
import Network.TypedProtocol.Codec (AnyMessage (..))
25-
import Data.Aeson (Value (String), (.=))
26-
import Data.Text (Text, pack)
27-
28-
--------------------------------------------------------------------------------
29-
-- Handshake Tracer
30-
--------------------------------------------------------------------------------
31-
32-
instance (Show term, Show ntcVersion) =>
33-
LogFormatting (AnyMessage (HS.Handshake ntcVersion term)) where
34-
forMachine _dtal (AnyMessageAndAgency stok msg) =
35-
mconcat [ "kind" .= String kind
36-
, "msg" .= (String . showT $ msg)
37-
, "agency" .= String (pack $ show stok)
38-
]
39-
where
40-
kind = case msg of
41-
HS.MsgProposeVersions {} -> "ProposeVersions"
42-
HS.MsgReplyVersions {} -> "ReplyVersions"
43-
HS.MsgQueryReply {} -> "QueryReply"
44-
HS.MsgAcceptVersion {} -> "AcceptVersion"
45-
HS.MsgRefuse {} -> "Refuse"
46-
47-
forHuman (AnyMessageAndAgency stok msg) =
48-
"Handshake (agency, message) = " <> "(" <> showT stok <> "," <> showT msg <> ")"
49-
50-
instance MetaTrace (AnyMessage (HS.Handshake a b)) where
51-
namespaceFor (AnyMessage msg) = Namespace [] $ case msg of
52-
HS.MsgProposeVersions {} -> ["ProposeVersions"]
53-
HS.MsgReplyVersions {} -> ["ReplyVersions"]
54-
HS.MsgQueryReply {} -> ["QueryReply"]
55-
HS.MsgAcceptVersion {} -> ["AcceptVersion"]
56-
HS.MsgRefuse {} -> ["Refuse"]
57-
58-
severityFor (Namespace _ [sym]) _ = case sym of
59-
"ProposeVersions" -> Just Info
60-
"ReplyVersions" -> Just Info
61-
"QueryReply" -> Just Info
62-
"AcceptVersion" -> Just Info
63-
"Refuse" -> Just Info
64-
_otherwise -> Nothing
65-
severityFor _ _ = Nothing
66-
67-
documentFor (Namespace _ sym) = wrap . mconcat $ case sym of
68-
["ProposeVersions"] ->
69-
[ "Propose versions together with version parameters. It must be"
70-
, " encoded to a sorted list.."
71-
]
72-
["ReplyVersions"] ->
73-
[ "`MsgReplyVersions` received as a response to 'MsgProposeVersions'. It"
74-
, " is not supported to explicitly send this message. It can only be"
75-
, " received as a copy of 'MsgProposeVersions' in a simultaneous open"
76-
, " scenario."
77-
]
78-
["QueryReply"] ->
79-
[ "`MsgQueryReply` received as a response to a handshake query in "
80-
, " 'MsgProposeVersions' and lists the supported versions."
81-
]
82-
["AcceptVersion"] ->
83-
[ "The remote end decides which version to use and sends chosen version."
84-
, "The server is allowed to modify version parameters."
85-
]
86-
["Refuse"] -> ["It refuses to run any version."]
87-
_otherwise -> [] :: [Text]
88-
where
89-
wrap it = case it of
90-
"" -> Nothing
91-
it' -> Just it'
92-
93-
allNamespaces = [
94-
Namespace [] ["ProposeVersions"]
95-
, Namespace [] ["ReplyVersions"]
96-
, Namespace [] ["QueryReply"]
97-
, Namespace [] ["AcceptVersion"]
98-
, Namespace [] ["Refuse"]
99-
]
10022

cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs

Lines changed: 1 addition & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ module Cardano.Node.Tracing.Tracers.NodeToClient () where
1212

1313
import Cardano.Logging
1414
import Ouroboros.Consensus.Ledger.Query (Query)
15-
import qualified Ouroboros.Network.Driver.Simple as Simple
16-
import qualified Ouroboros.Network.Driver.Stateful as Stateful
15+
import Ouroboros.Network.Logging.Framework ()
1716
import Ouroboros.Network.Protocol.ChainSync.Type as ChainSync
1817
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LSQ
1918
import qualified Ouroboros.Network.Protocol.LocalTxMonitor.Type as LTM
@@ -26,139 +25,6 @@ import qualified Network.TypedProtocol.Stateful.Codec as Stateful
2625

2726
{-# ANN module ("HLint: ignore Redundant bracket" :: Text) #-}
2827

29-
instance LogFormatting (Simple.AnyMessage ps)
30-
=> LogFormatting (Simple.TraceSendRecv ps) where
31-
forMachine dtal (Simple.TraceSendMsg m) = mconcat
32-
[ "kind" .= String "Send" , "msg" .= forMachine dtal m ]
33-
forMachine dtal (Simple.TraceRecvMsg m) = mconcat
34-
[ "kind" .= String "Recv" , "msg" .= forMachine dtal m ]
35-
36-
forHuman (Simple.TraceSendMsg m) = "Send: " <> forHumanOrMachine m
37-
forHuman (Simple.TraceRecvMsg m) = "Receive: " <> forHumanOrMachine m
38-
39-
asMetrics (Simple.TraceSendMsg m) = asMetrics m
40-
asMetrics (Simple.TraceRecvMsg m) = asMetrics m
41-
42-
instance LogFormatting (Stateful.AnyMessage ps f)
43-
=> LogFormatting (Stateful.TraceSendRecv ps f) where
44-
forMachine dtal (Stateful.TraceSendMsg m) = mconcat
45-
[ "kind" .= String "Send" , "msg" .= forMachine dtal m ]
46-
forMachine dtal (Stateful.TraceRecvMsg m) = mconcat
47-
[ "kind" .= String "Recv" , "msg" .= forMachine dtal m ]
48-
49-
forHuman (Stateful.TraceSendMsg m) = "Send: " <> forHumanOrMachine m
50-
forHuman (Stateful.TraceRecvMsg m) = "Receive: " <> forHumanOrMachine m
51-
52-
asMetrics (Stateful.TraceSendMsg m) = asMetrics m
53-
asMetrics (Stateful.TraceRecvMsg m) = asMetrics m
54-
55-
instance MetaTrace (Simple.AnyMessage ps) =>
56-
MetaTrace (Simple.TraceSendRecv ps) where
57-
namespaceFor (Simple.TraceSendMsg msg) =
58-
nsPrependInner "Send" (namespaceFor msg)
59-
namespaceFor (Simple.TraceRecvMsg msg) =
60-
nsPrependInner "Receive" (namespaceFor msg)
61-
62-
severityFor (Namespace out ("Send" : tl)) (Just (Simple.TraceSendMsg msg)) =
63-
severityFor (Namespace out tl) (Just msg)
64-
severityFor (Namespace out ("Send" : tl)) Nothing =
65-
severityFor (Namespace out tl :: Namespace (Simple.AnyMessage ps)) Nothing
66-
severityFor (Namespace out ("Receive" : tl)) (Just (Simple.TraceSendMsg msg)) =
67-
severityFor (Namespace out tl) (Just msg)
68-
severityFor (Namespace out ("Receive" : tl)) Nothing =
69-
severityFor (Namespace out tl :: Namespace (Simple.AnyMessage ps)) Nothing
70-
severityFor _ _ = Nothing
71-
72-
privacyFor (Namespace out ("Send" : tl)) (Just (Simple.TraceSendMsg msg)) =
73-
privacyFor (Namespace out tl) (Just msg)
74-
privacyFor (Namespace out ("Send" : tl)) Nothing =
75-
privacyFor (Namespace out tl :: Namespace (Simple.AnyMessage ps)) Nothing
76-
privacyFor (Namespace out ("Receive" : tl)) (Just (Simple.TraceSendMsg msg)) =
77-
privacyFor (Namespace out tl) (Just msg)
78-
privacyFor (Namespace out ("Receive" : tl)) Nothing =
79-
privacyFor (Namespace out tl :: Namespace (Simple.AnyMessage ps)) Nothing
80-
privacyFor _ _ = Nothing
81-
82-
detailsFor (Namespace out ("Send" : tl)) (Just (Simple.TraceSendMsg msg)) =
83-
detailsFor (Namespace out tl) (Just msg)
84-
detailsFor (Namespace out ("Send" : tl)) Nothing =
85-
detailsFor (Namespace out tl :: Namespace (Simple.AnyMessage ps)) Nothing
86-
detailsFor (Namespace out ("Receive" : tl)) (Just (Simple.TraceSendMsg msg)) =
87-
detailsFor (Namespace out tl) (Just msg)
88-
detailsFor (Namespace out ("Receive" : tl)) Nothing =
89-
detailsFor (Namespace out tl :: Namespace (Simple.AnyMessage ps)) Nothing
90-
detailsFor _ _ = Nothing
91-
92-
metricsDocFor (Namespace out ("Send" : tl)) =
93-
metricsDocFor (nsCast (Namespace out tl) :: Namespace (Simple.AnyMessage ps))
94-
metricsDocFor (Namespace out ("Receive" : tl)) =
95-
metricsDocFor (nsCast (Namespace out tl) :: Namespace (Simple.AnyMessage ps))
96-
metricsDocFor _ = []
97-
98-
documentFor (Namespace out ("Send" : tl)) =
99-
documentFor (nsCast (Namespace out tl) :: Namespace (Simple.AnyMessage ps))
100-
documentFor (Namespace out ("Receive" : tl)) =
101-
documentFor (nsCast (Namespace out tl) :: Namespace (Simple.AnyMessage ps))
102-
documentFor _ = Nothing
103-
104-
allNamespaces =
105-
let cn = allNamespaces :: [Namespace (Simple.AnyMessage ps)]
106-
in fmap (nsPrependInner "Send") cn ++ fmap (nsPrependInner "Receive") cn
107-
108-
instance MetaTrace (Stateful.AnyMessage ps f) =>
109-
MetaTrace (Stateful.TraceSendRecv ps f) where
110-
namespaceFor (Stateful.TraceSendMsg msg) =
111-
nsPrependInner "Send" (namespaceFor msg)
112-
namespaceFor (Stateful.TraceRecvMsg msg) =
113-
nsPrependInner "Receive" (namespaceFor msg)
114-
115-
severityFor (Namespace out ("Send" : tl)) (Just (Stateful.TraceSendMsg msg)) =
116-
severityFor (Namespace out tl) (Just msg)
117-
severityFor (Namespace out ("Send" : tl)) Nothing =
118-
severityFor (Namespace out tl :: Namespace (Stateful.AnyMessage ps f)) Nothing
119-
severityFor (Namespace out ("Receive" : tl)) (Just (Stateful.TraceSendMsg msg)) =
120-
severityFor (Namespace out tl) (Just msg)
121-
severityFor (Namespace out ("Receive" : tl)) Nothing =
122-
severityFor (Namespace out tl :: Namespace (Stateful.AnyMessage ps f)) Nothing
123-
severityFor _ _ = Nothing
124-
125-
privacyFor (Namespace out ("Send" : tl)) (Just (Stateful.TraceSendMsg msg)) =
126-
privacyFor (Namespace out tl) (Just msg)
127-
privacyFor (Namespace out ("Send" : tl)) Nothing =
128-
privacyFor (Namespace out tl :: Namespace (Stateful.AnyMessage ps f)) Nothing
129-
privacyFor (Namespace out ("Receive" : tl)) (Just (Stateful.TraceSendMsg msg)) =
130-
privacyFor (Namespace out tl) (Just msg)
131-
privacyFor (Namespace out ("Receive" : tl)) Nothing =
132-
privacyFor (Namespace out tl :: Namespace (Stateful.AnyMessage ps f)) Nothing
133-
privacyFor _ _ = Nothing
134-
135-
detailsFor (Namespace out ("Send" : tl)) (Just (Stateful.TraceSendMsg msg)) =
136-
detailsFor (Namespace out tl) (Just msg)
137-
detailsFor (Namespace out ("Send" : tl)) Nothing =
138-
detailsFor (Namespace out tl :: Namespace (Stateful.AnyMessage ps f)) Nothing
139-
detailsFor (Namespace out ("Receive" : tl)) (Just (Stateful.TraceSendMsg msg)) =
140-
detailsFor (Namespace out tl) (Just msg)
141-
detailsFor (Namespace out ("Receive" : tl)) Nothing =
142-
detailsFor (Namespace out tl :: Namespace (Stateful.AnyMessage ps f)) Nothing
143-
detailsFor _ _ = Nothing
144-
145-
metricsDocFor (Namespace out ("Send" : tl)) =
146-
metricsDocFor (nsCast (Namespace out tl) :: Namespace (Stateful.AnyMessage ps f))
147-
metricsDocFor (Namespace out ("Receive" : tl)) =
148-
metricsDocFor (nsCast (Namespace out tl) :: Namespace (Stateful.AnyMessage ps f))
149-
metricsDocFor _ = []
150-
151-
documentFor (Namespace out ("Send" : tl)) =
152-
documentFor (nsCast (Namespace out tl) :: Namespace (Stateful.AnyMessage ps f))
153-
documentFor (Namespace out ("Receive" : tl)) =
154-
documentFor (nsCast (Namespace out tl) :: Namespace (Stateful.AnyMessage ps f))
155-
documentFor _ = Nothing
156-
157-
allNamespaces =
158-
let cn = allNamespaces :: [Namespace (Stateful.AnyMessage ps f)]
159-
in fmap (nsPrependInner "Send") cn ++ fmap (nsPrependInner "Receive") cn
160-
161-
16228
-- --------------------------------------------------------------------------------
16329
-- -- TChainSync Tracer
16430
-- --------------------------------------------------------------------------------

cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Ouroboros.Network.InboundGovernor as InboundGovernor (Trace (..
3131
import qualified Ouroboros.Network.InboundGovernor as InboundGovernor
3232
import Ouroboros.Network.InboundGovernor.State as InboundGovernor (Counters (..))
3333
import Ouroboros.Network.Logging ()
34+
import Ouroboros.Network.Logging.Framework ()
3435
import qualified Ouroboros.Network.NodeToNode as NtN
3536
import Ouroboros.Network.OrphanInstances ()
3637
import Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (..),
@@ -63,14 +64,6 @@ import Data.Text (pack)
6364
import Network.Socket (SockAddr (..))
6465

6566

66-
--------------------------------------------------------------------------------
67-
-- Addresses
68-
--------------------------------------------------------------------------------
69-
70-
instance LogFormatting LocalAddress where
71-
forMachine _dtal (LocalAddress path) =
72-
mconcat ["path" .= path]
73-
7467
--------------------------------------------------------------------------------
7568
-- LocalRootPeers Tracer
7669
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)