@@ -11,14 +11,19 @@ module Cardano.Shell.Features.Logging
11
11
, Configuration
12
12
, LoggerName
13
13
, Severity (.. )
14
+ , mkLOMeta
15
+ , LOMeta (.. )
16
+ , LOContent (.. )
14
17
) where
15
18
19
+ import Control.Exception.Safe (MonadCatch )
16
20
import qualified Control.Monad.STM as STM
17
21
import Cardano.Prelude hiding (trace )
18
22
19
23
import Cardano.BM.Configuration (Configuration )
20
24
import qualified Cardano.BM.Configuration as Config
21
- import Cardano.BM.Data.LogItem (LoggerName )
25
+ import Cardano.BM.Data.LogItem (LoggerName , LOMeta (.. ),
26
+ LOContent (.. ), mkLOMeta )
22
27
import Cardano.BM.Data.Severity (Severity (.. ))
23
28
import qualified Cardano.BM.Observer.Monadic as Monadic
24
29
import qualified Cardano.BM.Observer.STM as Stm
@@ -63,9 +68,11 @@ data LoggingLayer = LoggingLayer
63
68
, llLogWarning :: forall m a . (MonadIO m , Show a ) => Trace m a -> a -> m ()
64
69
, llLogError :: forall m a . (MonadIO m , Show a ) => Trace m a -> a -> m ()
65
70
, llAppendName :: forall m a . (MonadIO m , Show a ) => LoggerName -> Trace m a -> m (Trace m a )
66
- , llConfiguration :: Configuration
67
- , llBracketMonadX :: forall m a t . (MonadIO m , Show a ) => Configuration -> Trace m a -> Severity -> Text -> m t -> m t
68
- , llBracketStmIO :: forall a t . (Show a ) => Configuration -> Trace IO a -> Severity -> Text -> STM. STM t -> IO t
71
+ , llBracketMonadIO :: forall a t . (Show a ) => Trace IO a -> Severity -> Text -> IO t -> IO t
72
+ , llBracketMonadM :: forall a m t . (MonadCatch m , MonadIO m , Show a ) => Trace m a -> Severity -> Text -> m t -> m t
73
+ , llBracketMonadX :: forall m a t . (MonadIO m , Show a ) => Trace m a -> Severity -> Text -> m t -> m t
74
+ , llBracketStmIO :: forall a t . (Show a ) => Trace IO a -> Severity -> Text -> STM. STM t -> IO t
75
+ , llBracketStmLogIO :: forall a t . (Show a ) => Trace IO a -> Severity -> Text -> STM. STM (t ,[(LOMeta , LOContent a )]) -> IO t
69
76
}
70
77
71
78
--------------------------------
@@ -99,8 +106,8 @@ createLoggingFeature cardanoEnvironment cardanoConfiguration = do
99
106
-- | Initialize `LoggingCardanoFeature`
100
107
loggingCardanoFeatureInit :: LoggingParameters -> IO LoggingCardanoFeature
101
108
loggingCardanoFeatureInit loggingConfig = do
102
-
103
- (baseTrace, switchBoard) <- setupTrace_ (lpConfiguration loggingConfig) " cardano"
109
+ let logconfig = lpConfiguration loggingConfig
110
+ (baseTrace, switchBoard) <- setupTrace_ logconfig " cardano"
104
111
105
112
let initLogging :: CardanoEnvironment -> NoDependency -> CardanoConfiguration -> LoggingParameters -> IO LoggingLayer
106
113
initLogging _ _ _ _ = do
@@ -112,9 +119,11 @@ loggingCardanoFeatureInit loggingConfig = do
112
119
, llLogWarning = Trace. logWarning
113
120
, llLogError = Trace. logError
114
121
, llAppendName = Trace. appendName
115
- , llConfiguration = lpConfiguration loggingConfig
116
- , llBracketMonadX = Monadic. bracketObserveX
117
- , llBracketStmIO = Stm. bracketObserveIO
122
+ , llBracketMonadIO = Monadic. bracketObserveIO logconfig
123
+ , llBracketMonadM = Monadic. bracketObserveM logconfig
124
+ , llBracketMonadX = Monadic. bracketObserveX logconfig
125
+ , llBracketStmIO = Stm. bracketObserveIO logconfig
126
+ , llBracketStmLogIO = Stm. bracketObserveLogIO logconfig
118
127
}
119
128
let cleanupLogging :: LoggingLayer -> IO ()
120
129
cleanupLogging _ = shutdown switchBoard
0 commit comments