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

[GH-99] T5.1.1 simplified logging feature #159

Merged
merged 2 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions app/Cardano/Shell/Features/Logging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ module Cardano.Shell.Features.Logging
, Configuration
, LoggerName
, Severity (..)
, mkLOMeta
, LOMeta (..)
, LOContent (..)
) where

import Control.Exception.Safe (MonadCatch)
import qualified Control.Monad.STM as STM
import Cardano.Prelude hiding (trace)

import Cardano.BM.Configuration (Configuration)
import qualified Cardano.BM.Configuration as Config
import Cardano.BM.Data.LogItem (LoggerName)
import Cardano.BM.Data.LogItem (LoggerName, LOMeta (..),
LOContent (..), mkLOMeta)
import Cardano.BM.Data.Severity (Severity (..))
import qualified Cardano.BM.Observer.Monadic as Monadic
import qualified Cardano.BM.Observer.STM as Stm
Expand Down Expand Up @@ -63,9 +68,11 @@ data LoggingLayer = LoggingLayer
, llLogWarning :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
, llLogError :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
, llAppendName :: forall m a. (MonadIO m, Show a) => LoggerName -> Trace m a -> m (Trace m a)
, llConfiguration :: Configuration
, llBracketMonadX :: forall m a t. (MonadIO m, Show a) => Configuration -> Trace m a -> Severity -> Text -> m t -> m t
, llBracketStmIO :: forall a t. (Show a) => Configuration -> Trace IO a -> Severity -> Text -> STM.STM t -> IO t
, llBracketMonadIO :: forall a t. (Show a) => Trace IO a -> Severity -> Text -> IO t -> IO t
, llBracketMonadM :: forall a m t. (MonadCatch m, MonadIO m, Show a) => Trace m a -> Severity -> Text -> m t -> m t
, llBracketMonadX :: forall m a t. (MonadIO m, Show a) => Trace m a -> Severity -> Text -> m t -> m t
, llBracketStmIO :: forall a t. (Show a) => Trace IO a -> Severity -> Text -> STM.STM t -> IO t
, llBracketStmLogIO :: forall a t. (Show a) => Trace IO a -> Severity -> Text -> STM.STM (t,[(LOMeta, LOContent a)]) -> IO t
}

--------------------------------
Expand Down Expand Up @@ -99,8 +106,8 @@ createLoggingFeature cardanoEnvironment cardanoConfiguration = do
-- | Initialize `LoggingCardanoFeature`
loggingCardanoFeatureInit :: LoggingParameters -> IO LoggingCardanoFeature
loggingCardanoFeatureInit loggingConfig = do

(baseTrace, switchBoard) <- setupTrace_ (lpConfiguration loggingConfig) "cardano"
let logconfig = lpConfiguration loggingConfig
(baseTrace, switchBoard) <- setupTrace_ logconfig "cardano"

let initLogging :: CardanoEnvironment -> NoDependency -> CardanoConfiguration -> LoggingParameters -> IO LoggingLayer
initLogging _ _ _ _ = do
Expand All @@ -112,9 +119,11 @@ loggingCardanoFeatureInit loggingConfig = do
, llLogWarning = Trace.logWarning
, llLogError = Trace.logError
, llAppendName = Trace.appendName
, llConfiguration = lpConfiguration loggingConfig
, llBracketMonadX = Monadic.bracketObserveX
, llBracketStmIO = Stm.bracketObserveIO
, llBracketMonadIO = Monadic.bracketObserveIO logconfig
, llBracketMonadM = Monadic.bracketObserveM logconfig
, llBracketMonadX = Monadic.bracketObserveX logconfig
, llBracketStmIO = Stm.bracketObserveIO logconfig
, llBracketStmLogIO = Stm.bracketObserveLogIO logconfig
}
let cleanupLogging :: LoggingLayer -> IO ()
cleanupLogging _ = shutdown switchBoard
Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d4139f18f77d2f837d52383859a27974f4f4e162
tag: cbe7ab32354f3838dc8c95c64109904c8f503347
subdir: contra-tracer

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: d4139f18f77d2f837d52383859a27974f4f4e162
tag: cbe7ab32354f3838dc8c95c64109904c8f503347
subdir: iohk-monitoring

with-compiler: ghc-8.6.4
6 changes: 5 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extra-deps:
- test

- git: https://github.com/input-output-hk/iohk-monitoring-framework
commit: d4139f18f77d2f837d52383859a27974f4f4e162
commit: cbe7ab32354f3838dc8c95c64109904c8f503347
subdirs:
- contra-tracer
- iohk-monitoring
Expand All @@ -67,6 +67,10 @@ extra-deps:

- ekg-json-0.1.0.6@sha256:4ff2e9cac213a5868ae8b4a7c72a16a9a76fac14d944ae819b3d838a9725569b

- ekg-prometheus-adapter-0.1.0.4
- prometheus-2.1.1
- containers-0.5.11.0

# Override default flag values for local packages and extra-deps
# flags: {}

Expand Down