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

Commit acf5b26

Browse files
CodiePPksaric
authored andcommitted
[GH-99] T5.1.1 added configuration to logging feature (#90)
* [#228] T3.1.2 added configuration to logging feature Signed-off-by: Alexander Diemand <[email protected]> * [GH-99] export types and functions via the logging feature Signed-off-by: Alexander Diemand <[email protected]> * [GH-99] export LoggerName Signed-off-by: Alexander Diemand <[email protected]> * [GH-99] check operating system in cabal file Signed-off-by: Alexander Diemand <[email protected]> * [GH-99] less comments Signed-off-by: Alexander Diemand <[email protected]>
1 parent a7de18d commit acf5b26

File tree

8 files changed

+68
-43
lines changed

8 files changed

+68
-43
lines changed

app/Cardano/Shell/Features/Logging.hs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66
module Cardano.Shell.Features.Logging
77
( LoggingLayer (..)
88
, createLoggingFeature
9+
-- re-exports
910
, Trace
11+
, Configuration
12+
, LoggerName
13+
, Severity (..)
1014
) where
1115

16+
import qualified Control.Monad.STM as STM
1217
import Cardano.Prelude hiding (trace)
1318

1419
import Cardano.BM.Configuration (Configuration)
1520
import qualified Cardano.BM.Configuration as Config
1621
import Cardano.BM.Data.LogItem (LoggerName)
22+
import Cardano.BM.Data.Severity (Severity (..))
23+
import qualified Cardano.BM.Observer.Monadic as Monadic
24+
import qualified Cardano.BM.Observer.STM as Stm
1725
import Cardano.BM.Setup (setupTrace_, shutdown)
1826
import Cardano.BM.Trace (Trace)
1927
import qualified Cardano.BM.Trace as Trace
@@ -48,13 +56,16 @@ data LoggingParameters = LoggingParameters
4856
-- the functions effects and constraining the user (programmer) of those function to use specific effects in them.
4957
-- https://github.com/input-output-hk/cardano-sl/blob/develop/util/src/Pos/Util/Log/LogSafe.hs
5058
data LoggingLayer = LoggingLayer
51-
{ llBasicTrace :: forall m . MonadIO m => Trace m Text
52-
, llLogDebug :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
53-
, llLogInfo :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
54-
, llLogNotice :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
55-
, llLogWarning :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
56-
, llLogError :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
57-
, llAppendName :: forall m a. (MonadIO m, Show a) => LoggerName -> Trace m a -> m (Trace m a)
59+
{ llBasicTrace :: forall m . MonadIO m => Trace m Text
60+
, llLogDebug :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
61+
, llLogInfo :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
62+
, llLogNotice :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
63+
, llLogWarning :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
64+
, llLogError :: forall m a. (MonadIO m, Show a) => Trace m a -> a -> m ()
65+
, 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
5869
}
5970

6071
--------------------------------
@@ -94,13 +105,16 @@ loggingCardanoFeatureInit loggingConfig = do
94105
let initLogging :: CardanoEnvironment -> NoDependency -> CardanoConfiguration -> LoggingParameters -> IO LoggingLayer
95106
initLogging _ _ _ _ = do
96107
pure $ LoggingLayer
97-
{ llBasicTrace = Trace.natTrace liftIO baseTrace
98-
, llLogDebug = Trace.logDebug
99-
, llLogInfo = Trace.logInfo
100-
, llLogNotice = Trace.logNotice
101-
, llLogWarning = Trace.logWarning
102-
, llLogError = Trace.logError
103-
, llAppendName = Trace.appendName
108+
{ llBasicTrace = Trace.natTrace liftIO baseTrace
109+
, llLogDebug = Trace.logDebug
110+
, llLogInfo = Trace.logInfo
111+
, llLogNotice = Trace.logNotice
112+
, llLogWarning = Trace.logWarning
113+
, llLogError = Trace.logError
114+
, llAppendName = Trace.appendName
115+
, llConfiguration = lpConfiguration loggingConfig
116+
, llBracketMonadX = Monadic.bracketObserveX
117+
, llBracketStmIO = Stm.bracketObserveIO
104118
}
105119
let cleanupLogging :: LoggingLayer -> IO ()
106120
cleanupLogging _ = shutdown switchBoard

cabal.project

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
source-repository-package
3+
type: git
4+
location: https://github.com/input-output-hk/iohk-monitoring-framework
5+
tag: d4139f18f77d2f837d52383859a27974f4f4e162
6+
subdir: contra-tracer
7+
8+
source-repository-package
9+
type: git
10+
location: https://github.com/input-output-hk/iohk-monitoring-framework
11+
tag: d4139f18f77d2f837d52383859a27974f4f4e162
12+
subdir: iohk-monitoring
13+
14+
with-compiler: ghc-8.6.4

cardano-shell.cabal

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,28 @@ library
4545
, specs
4646
build-depends:
4747
aeson
48-
, base >=4.7 && <5
48+
, base >=4.11 && <5
4949
, binary
5050
, bytestring
51-
, cardano-prelude
5251
, Cabal
52+
, cardano-prelude
5353
, concurrency
54-
-- general util
5554
, containers
55+
, contravariant
56+
, dhall
5657
, directory
5758
, formatting
5859
, iohk-monitoring
59-
, safe-exceptions
60-
, text
61-
, transformers
62-
, unix
63-
-- json & config
64-
, contravariant
65-
, dhall
66-
, ekg-core
6760
, process
6861
, QuickCheck
62+
, safe-exceptions
63+
, stm
6964
, text
7065
, transformers
71-
, unix
66+
if os(windows)
67+
build-depends: Win32
68+
else
69+
build-depends: unix
7270

7371
default-language: Haskell2010
7472
default-extensions: NoImplicitPrelude
@@ -96,6 +94,7 @@ executable cardano-shell-exe
9694
, cardano-prelude
9795
-- util
9896
, safe-exceptions
97+
, stm
9998
-- features
10099
, iohk-monitoring
101100
default-language: Haskell2010
@@ -149,7 +148,6 @@ executable cardano-launcher
149148
, async
150149
-- process managment
151150
, process
152-
, unix
153151
, turtle
154152
-- directory
155153
, directory
@@ -158,6 +156,11 @@ executable cardano-launcher
158156
, formatting
159157
-- exception handling
160158
, safe-exceptions
159+
if os(windows)
160+
build-depends: Win32
161+
else
162+
build-depends: unix
163+
161164
default-language: Haskell2010
162165
default-extensions: NoImplicitPrelude
163166
OverloadedStrings

cardano-shell.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{ mkDerivation, aeson, async, base, binary, bytestring, Cabal
22
, cardano-prelude, cardano-sl-x509, concurrency, containers
3-
, contravariant, dejafu, dhall, directory, ekg-core, filepath
3+
, contravariant, dejafu, dhall, directory, filepath
44
, formatting, hspec, hspec-contrib, hunit-dejafu, iohk-monitoring
5-
, process, QuickCheck, safe-exceptions, stdenv, text, transformers
5+
, process, QuickCheck, safe-exceptions, stdenv, stm, text, transformers
66
, turtle, unix
77
}:
88
mkDerivation {
@@ -13,8 +13,8 @@ mkDerivation {
1313
isExecutable = true;
1414
libraryHaskellDepends = [
1515
aeson base binary bytestring Cabal cardano-prelude concurrency
16-
containers contravariant dhall directory ekg-core formatting
17-
iohk-monitoring process QuickCheck safe-exceptions text
16+
containers contravariant dhall directory formatting
17+
iohk-monitoring process QuickCheck safe-exceptions stm text
1818
transformers unix
1919
];
2020
executableHaskellDepends = [

iohk-monitoring-contra-tracer.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ mkDerivation {
66
version = "0.1.0.0";
77
src = fetchgit {
88
url = "https://github.com/input-output-hk/iohk-monitoring-framework";
9-
sha256 = "16sxwx8y2wg8kws15ybhk9vkq6crs5bp7ky37x1vrvpvb3ilc5x0";
10-
rev = "8fb87e83468831289820ef9edb3d5ef912b0db0f";
9+
sha256 = "02yr3alnf74qpa8vg1kk9h034blmb4nzpsbzb0n5jymsyy8r1i4c";
10+
rev = "d4139f18f77d2f837d52383859a27974f4f4e162";
1111
fetchSubmodules = true;
1212
};
1313
postUnpack = "sourceRoot+=/contra-tracer; echo source root reset to $sourceRoot";

iohk-monitoring.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
}:
1010
mkDerivation {
1111
pname = "iohk-monitoring";
12-
version = "0.1.5.0";
12+
version = "0.1.7.1";
1313
src = fetchgit {
1414
url = "https://github.com/input-output-hk/iohk-monitoring-framework";
15-
sha256 = "16sxwx8y2wg8kws15ybhk9vkq6crs5bp7ky37x1vrvpvb3ilc5x0";
16-
rev = "8fb87e83468831289820ef9edb3d5ef912b0db0f";
15+
sha256 = "02yr3alnf74qpa8vg1kk9h034blmb4nzpsbzb0n5jymsyy8r1i4c";
16+
rev = "d4139f18f77d2f837d52383859a27974f4f4e162";
1717
fetchSubmodules = true;
1818
};
1919
postUnpack = "sourceRoot+=/iohk-monitoring; echo source root reset to $sourceRoot";

src/Cardano/Shell/Types.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import Control.Concurrent.Classy (MonadConc)
1717

1818
import Cardano.Shell.Constants.Types (CardanoConfiguration (..))
1919

20-
import qualified System.Metrics as Ekg
21-
2220
-- | The top level module we use to run the key functions.
2321
newtype CardanoApplication = CardanoApplication { runCardanoApplication :: IO () }
2422

@@ -37,17 +35,13 @@ applicationProductionMode _ = False
3735
-- All features have access to this environment.
3836
data CardanoEnvironment = CardanoEnvironment
3937
{ ceLogEnv :: Text
40-
, ceEkgStore :: Ekg.Store
41-
-- ...
4238
}
4339

4440
-- | Initialise 'ServerEnv'
4541
initializeCardanoEnvironment :: IO CardanoEnvironment
4642
initializeCardanoEnvironment = do
47-
ekgStore <- Ekg.newStore
4843
return CardanoEnvironment
4944
{ ceLogEnv = "To implement"
50-
, ceEkgStore = ekgStore
5145
}
5246

5347
-- | The option to not have any additional dependency for the @CardanoFeature@.

stack.yaml

Lines changed: 1 addition & 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: 8fb87e83468831289820ef9edb3d5ef912b0db0f
50+
commit: d4139f18f77d2f837d52383859a27974f4f4e162
5151
subdirs:
5252
- contra-tracer
5353
- iohk-monitoring

0 commit comments

Comments
 (0)