3
3
4
4
module Main where
5
5
6
- import Hydra.Cardano.Api
6
+ import Hydra.Cardano.Api ( Tx )
7
7
import Hydra.Prelude hiding (encodeUtf8 )
8
8
import Hydra.Prelude qualified as P
9
9
@@ -71,36 +71,36 @@ visualize paths = do
71
71
BeginEffect {effect} ->
72
72
case effect of
73
73
ClientEffect {} -> pure DropLog
74
- NetworkEffect {message} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " NETWORK EFFECT" (show message) green )
74
+ NetworkEffect {message} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " NETWORK EFFECT" (show message) magenta )
75
75
OnChainEffect {postChainTx} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " POSTING" (show postChainTx) blue)
76
76
EndEffect {} -> pure DropLog
77
77
LogicOutcome {outcome} ->
78
78
case outcome of
79
79
Continue {stateChanges} ->
80
80
foldM
81
81
( \ b a -> case a of
82
- HeadInitialized {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadInitialized" " " green )
83
- HeadOpened {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadOpened" " " green )
84
- CommittedUTxO {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " CommittedUTxO" " " green )
85
- HeadAborted {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadAborted" " " green )
86
- SnapshotRequestDecided {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " SnapshotRequestDecided" " " green )
87
- SnapshotRequested {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " SnapshotRequested" " " green )
88
- PartySignedSnapshot {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " PartySignedSnapshot" " " green )
89
- SnapshotConfirmed {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " SnapshotConfirmed" " " green )
90
- DepositRecorded {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositRecorded" " " green )
91
- DepositActivated {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositActivated" " " green )
82
+ HeadInitialized {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadInitialized" " " cyan )
83
+ HeadOpened {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadOpened" " " cyan )
84
+ CommittedUTxO {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " CommittedUTxO" " " cyan )
85
+ HeadAborted {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadAborted" " " red )
86
+ SnapshotRequestDecided {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " SnapshotRequestDecided" " " cyan )
87
+ SnapshotRequested {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " SnapshotRequested" " " cyan )
88
+ PartySignedSnapshot {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " PartySignedSnapshot" " " cyan )
89
+ SnapshotConfirmed {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " SnapshotConfirmed" " " cyan )
90
+ DepositRecorded {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositRecorded" " " cyan )
91
+ DepositActivated {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositActivated" " " cyan )
92
92
DepositExpired {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositExpired" " " red)
93
- DepositRecovered {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositRecovered" " " green )
94
- CommitApproved {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " CommitApproved" " " green )
95
- CommitFinalized {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " CommitFinalized" " " green )
96
- DecommitRecorded {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitRecorded" " " green )
97
- DecommitApproved {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitApproved" " " green )
98
- DecommitInvalid {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitInvalid" " " green )
99
- DecommitFinalized {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitFinalized" " " green )
93
+ DepositRecovered {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DepositRecovered" " " cyan )
94
+ CommitApproved {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " CommitApproved" " " cyan )
95
+ CommitFinalized {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " CommitFinalized" " " cyan )
96
+ DecommitRecorded {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitRecorded" " " cyan )
97
+ DecommitApproved {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitApproved" " " cyan )
98
+ DecommitInvalid {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitInvalid" " " red )
99
+ DecommitFinalized {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " DecommitFinalized" " " cyan )
100
100
HeadClosed {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadClosed" " " green)
101
- HeadContested {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadContested" " " green )
102
- HeadIsReadyToFanout {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadIsReadyToFanout" " " green )
103
- HeadFannedOut {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadFannedOut" " " green )
101
+ HeadContested {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadContested" " " cyan )
102
+ HeadIsReadyToFanout {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadIsReadyToFanout" " " cyan )
103
+ HeadFannedOut {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " HeadFannedOut" " " cyan )
104
104
IgnoredHeadInitializing {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " IgnoredHeadInitializing" " " red)
105
105
TxInvalid {} -> pure $ DecodedHydraLog decoded. timestamp decoded. namespace (InfoLine " TxInvalid" " " red)
106
106
_ -> pure b
@@ -129,7 +129,8 @@ decodeAs l _ =
129
129
130
130
render :: Decoded tx -> IO ()
131
131
render = \ case
132
- DecodedHydraLog {t, n, info = InfoLine {header, line, color}} -> putTextLn $ color <> unlines [" [" <> show t <> " ]" , " NAMESPACE:" <> show n, header, line]
132
+ DecodedHydraLog {t, n, info = InfoLine {header, line, color}} -> do
133
+ putTextLn $ color <> unlines [" [" <> show t <> " ]" , " NAMESPACE:" <> show n, header, line] <> reset
133
134
DropLog -> putTextLn " "
134
135
135
136
-- ANSI escape codes for colors
@@ -142,5 +143,11 @@ green = "\ESC[32m"
142
143
blue :: Text
143
144
blue = " \ESC [34m"
144
145
146
+ cyan :: Text
147
+ cyan = " \ESC [36m"
148
+
149
+ magenta :: Text
150
+ magenta = " \ESC [45m"
151
+
145
152
reset :: Text
146
153
reset = " \ESC [0m"
0 commit comments