Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 4e9651d

Browse files
authored
[GH-99] T5.1.1 simplified logging feature (#159)
* [GH-99] T5.1.1 simplified logging feature Signed-off-by: Alexander Diemand <[email protected]> * [GH-99] T5.1.1 updated iohk-monitoring Signed-off-by: Alexander Diemand <[email protected]>
1 parent 5db8e79 commit 4e9651d

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

app/Cardano/Shell/Features/Logging.hs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ module Cardano.Shell.Features.Logging
1111
, Configuration
1212
, LoggerName
1313
, Severity (..)
14+
, mkLOMeta
15+
, LOMeta (..)
16+
, LOContent (..)
1417
) where
1518

19+
import Control.Exception.Safe (MonadCatch)
1620
import qualified Control.Monad.STM as STM
1721
import Cardano.Prelude hiding (trace)
1822

1923
import Cardano.BM.Configuration (Configuration)
2024
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)
2227
import Cardano.BM.Data.Severity (Severity (..))
2328
import qualified Cardano.BM.Observer.Monadic as Monadic
2429
import qualified Cardano.BM.Observer.STM as Stm
@@ -63,9 +68,11 @@ data LoggingLayer = LoggingLayer
6368
, llLogWarning :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
6469
, llLogError :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
6570
, 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
6976
}
7077

7178
--------------------------------
@@ -99,8 +106,8 @@ createLoggingFeature cardanoEnvironment cardanoConfiguration = do
99106
-- | Initialize `LoggingCardanoFeature`
100107
loggingCardanoFeatureInit :: LoggingParameters -> IO LoggingCardanoFeature
101108
loggingCardanoFeatureInit loggingConfig = do
102-
103-
(baseTrace, switchBoard) <- setupTrace_ (lpConfiguration loggingConfig) "cardano"
109+
let logconfig = lpConfiguration loggingConfig
110+
(baseTrace, switchBoard) <- setupTrace_ logconfig "cardano"
104111

105112
let initLogging :: CardanoEnvironment -> NoDependency -> CardanoConfiguration -> LoggingParameters -> IO LoggingLayer
106113
initLogging _ _ _ _ = do
@@ -112,9 +119,11 @@ loggingCardanoFeatureInit loggingConfig = do
112119
, llLogWarning = Trace.logWarning
113120
, llLogError = Trace.logError
114121
, 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
118127
}
119128
let cleanupLogging :: LoggingLayer -> IO ()
120129
cleanupLogging _ = shutdown switchBoard

cabal.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
source-repository-package
33
type: git
44
location: https://github.com/input-output-hk/iohk-monitoring-framework
5-
tag: d4139f18f77d2f837d52383859a27974f4f4e162
5+
tag: cbe7ab32354f3838dc8c95c64109904c8f503347
66
subdir: contra-tracer
77

88
source-repository-package
99
type: git
1010
location: https://github.com/input-output-hk/iohk-monitoring-framework
11-
tag: d4139f18f77d2f837d52383859a27974f4f4e162
11+
tag: cbe7ab32354f3838dc8c95c64109904c8f503347
1212
subdir: iohk-monitoring
1313

1414
with-compiler: ghc-8.6.4

stack.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extra-deps:
4747
- test
4848

4949
- git: https://github.com/input-output-hk/iohk-monitoring-framework
50-
commit: d4139f18f77d2f837d52383859a27974f4f4e162
50+
commit: cbe7ab32354f3838dc8c95c64109904c8f503347
5151
subdirs:
5252
- contra-tracer
5353
- iohk-monitoring
@@ -67,6 +67,10 @@ extra-deps:
6767

6868
- ekg-json-0.1.0.6@sha256:4ff2e9cac213a5868ae8b4a7c72a16a9a76fac14d944ae819b3d838a9725569b
6969

70+
- ekg-prometheus-adapter-0.1.0.4
71+
- prometheus-2.1.1
72+
- containers-0.5.11.0
73+
7074
# Override default flag values for local packages and extra-deps
7175
# flags: {}
7276

0 commit comments

Comments
 (0)