\subsection{Cardano.BM.Configuration} \label{code:Cardano.BM.Configuration} %if style == newcode \begin{code} {-# LANGUAGE CPP #-} module Cardano.BM.Configuration ( CM.Configuration , CM.setup , CM.minSeverity , CM.setMinSeverity , CM.inspectSeverity , CM.setSeverity , CM.getAcceptAt , CM.getBackends , CM.getForwardTo , CM.setForwardTo , CM.getForwardDelay , CM.setForwardDelay , CM.getOption , CM.getMapOption , CM.getTextOption , CM.setOption , CM.setTextOption , CM.updateOption , CM.findSubTrace , CM.setSubTrace , CM.getEKGBindAddr , CM.getGraylogPort , CM.getPrometheusBindAddr , CM.getGUIport , CM.getMonitors , getTextOptionOrDefault , testSeverity , CM.evalFilters , CM.testSubTrace ) where import Data.Foldable (fold) import Data.Text (Text) import Data.Maybe (fromMaybe) import qualified Cardano.BM.Configuration.Model as CM import Cardano.BM.Data.LogItem \end{code} %endif see |Cardano.BM.Configuration.Model| for the implementation. \label{code:getOptionOrDefault}\index{getOptionOrDefault} \begin{code} getTextOptionOrDefault :: CM.Configuration -> Text -> Text -> IO Text getTextOptionOrDefault :: Configuration -> Text -> Text -> IO Text getTextOptionOrDefault Configuration cg Text name Text def = Text -> Maybe Text -> Text forall a. a -> Maybe a -> a fromMaybe Text def (Maybe Text -> Text) -> IO (Maybe Text) -> IO Text forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Configuration -> Text -> IO (Maybe Text) CM.getTextOption Configuration cg Text name \end{code} \subsubsection{Test severities}\label{code:testSeverity}\index{testSeverity} Test severity of the given |LOMeta| to be greater or equal to those of the specific |LoggerName|. \begin{code} testSeverity :: CM.Configuration -> LoggerName -> LOMeta -> IO Bool testSeverity :: Configuration -> Text -> LOMeta -> IO Bool testSeverity Configuration config Text loggername LOMeta meta = do Severity globminsev <- Configuration -> IO Severity CM.minSeverity Configuration config Maybe Severity globnamesev <- Configuration -> Text -> IO (Maybe Severity) CM.inspectSeverity Configuration config Text loggername let minsev :: Severity minsev = Severity globminsev Severity -> Severity -> Severity forall a. Semigroup a => a -> a -> a <> Maybe Severity -> Severity forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m fold Maybe Severity globnamesev Bool -> IO Bool forall (m :: * -> *) a. Monad m => a -> m a return (Bool -> IO Bool) -> Bool -> IO Bool forall a b. (a -> b) -> a -> b $ (LOMeta -> Severity severity LOMeta meta) Severity -> Severity -> Bool forall a. Ord a => a -> a -> Bool >= Severity minsev \end{code}