@@ -17,11 +17,12 @@ import Hydra.HeadLogic (Effect (..), Input (..), Outcome (..), StateChanged (..)
17
17
import Hydra.Logging (Envelope (.. ))
18
18
import Hydra.Logging.Messages (HydraLog (.. ))
19
19
import Hydra.Node (HydraNodeLog (.. ))
20
+ import Options.Applicative
20
21
21
22
data InfoLine = InfoLine { toplabel :: LogType , details :: Text } deriving (Eq , Show )
22
23
23
24
data Decoded tx
24
- = DecodedHydraLog { t :: UTCTime , n :: Text , info :: InfoLine }
25
+ = DecodedHydraLog { t :: UTCTime , n :: Text , infoLine :: InfoLine }
25
26
| DropLog
26
27
deriving (Eq , Show )
27
28
@@ -73,8 +74,34 @@ colorLog = \case
73
74
LogicError _ -> red
74
75
Other _ -> green
75
76
77
+ newtype Options = Options
78
+ { paths :: [FilePath ]
79
+ }
80
+ deriving (Show )
81
+
82
+ options :: Parser Options
83
+ options =
84
+ Options
85
+ <$> many
86
+ ( strArgument
87
+ ( metavar " FILES"
88
+ <> help " One or more log file paths."
89
+ )
90
+ )
91
+
92
+ opts :: ParserInfo Options
93
+ opts =
94
+ info
95
+ (options <**> helper)
96
+ ( fullDesc
97
+ <> progDesc " Group logs by the timestamp and display using colors and separators for easy inspection."
98
+ <> header " Visualize hydra-node logs"
99
+ )
100
+
76
101
main :: IO ()
77
- main = visualize [" ../devnet/alice-logs.txt" , " ../devnet/bob-logs.txt" ]
102
+ main = do
103
+ args <- execParser opts
104
+ visualize $ paths args
78
105
79
106
visualize :: [FilePath ] -> IO ()
80
107
visualize paths = do
@@ -182,7 +209,7 @@ processLogs decoded =
182
209
183
210
render :: Decoded tx -> IO ()
184
211
render = \ case
185
- DecodedHydraLog {t, n, info = InfoLine {toplabel, details}} -> do
212
+ DecodedHydraLog {t, n, infoLine = InfoLine {toplabel, details}} -> do
186
213
putTextLn $
187
214
unlines
188
215
[ " -----------------------------------"
0 commit comments