Skip to content

Commit

Permalink
Add minSeverity option to local-cluster CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed May 9, 2024
1 parent 4e9f63b commit 2ee86f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/local-cluster/exe/local-cluster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ main = withUtf8 $ do
, clusterLogs
, nodeToClientSocket
, httpService
, minSeverity
} <-
parseCommandLineOptions
evalContT $ do
Expand All @@ -250,7 +251,7 @@ main = withUtf8 $ do
ContT
$ newToTextTracer
(toFilePath . absFileOf <$> clusterLogs)
Nothing
minSeverity

-- Create a temporary directory for the cluster
clusterPath <-
Expand Down
30 changes: 30 additions & 0 deletions lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/CommandLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ where

import Prelude

import Cardano.BM.Data.Severity
( Severity
)
import Cardano.Wallet.Launch.Cluster.FileOf
( Absolutizer (..)
, DirOf (..)
Expand Down Expand Up @@ -51,10 +54,13 @@ import System.Path
( absRel
)

import qualified Cardano.BM.Data.Severity as Severity

data CommandLineOptions = CommandLineOptions
{ clusterConfigsDir :: DirOf "cluster-configs"
, clusterDir :: Maybe (DirOf "cluster")
, clusterLogs :: Maybe (FileOf "cluster-logs")
, minSeverity :: Maybe Severity
, nodeToClientSocket :: FileOf "node-to-client-socket"
, httpService :: ServiceConfiguration
}
Expand All @@ -69,12 +75,36 @@ parseCommandLineOptions = do
<$> clusterConfigsDirParser absolutizer
<*> clusterDirParser absolutizer
<*> clusterLogsParser absolutizer
<*> minSeverityParser
<*> nodeToClientSocketParser absolutizer
<*> monitoringParser
<**> helper
)
(progDesc "Local Cluster for testing")

minSeverityParser :: Parser (Maybe Severity)
minSeverityParser =
optional
$ option
parse
( long "min-severity"
<> metavar "MIN_SEVERITY"
<> help "Minimum severity level for logging"
)
where
parse = do
s :: String <- auto
case s of
"Debug" -> pure Severity.Debug
"Info" -> pure Severity.Info
"Notice" -> pure Severity.Notice
"Warning" -> pure Severity.Warning
"Error" -> pure Severity.Error
"Critical" -> pure Severity.Critical
"Alert" -> pure Severity.Alert
"Emergency" -> pure Severity.Emergency
_ -> fail "Invalid severity level"

monitoringParser :: Parser ServiceConfiguration
monitoringParser =
mkServiceConfiguration
Expand Down

0 comments on commit 2ee86f5

Please sign in to comment.