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

Commit 043d186

Browse files
committed
[CBR-275] modifyLoggerName reqs 'dot' when adding name to context
Signed-off-by: Alexander Diemand <[email protected]>
1 parent a079e6b commit 043d186

File tree

12 files changed

+28
-21
lines changed

12 files changed

+28
-21
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# From daedalus-bridge
66
node_modules/*
77

8+
# tags
9+
*.tags
10+
tags
11+
812
# Config files
913
.ghci
1014

db/src/Pos/DB/Update/Logic/Global.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type USGlobalApplyMode ctx m =
7979
----------------------------------------------------------------------------
8080

8181
withUSLogger :: WithLogger m => m a -> m a
82-
withUSLogger = modifyLoggerName (<> "us")
82+
withUSLogger = modifyLoggerName (<> ".us")
8383

8484
-- | Apply chain of /definitely/ valid blocks to US part of GState DB
8585
-- and to US local data. This function assumes that no other thread

explorer/src/Pos/Explorer/Socket/App.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ notifierApp
228228
-> NotifierSettings
229229
-> m ()
230230
notifierApp genesisConfig settings =
231-
modifyLoggerName (<> "notifier.socket-io") $ do
231+
modifyLoggerName (<> ".notifier.socket-io") $ do
232232
logInfo "Starting"
233233
connVar <- liftIO $ STM.newTVarIO mkConnectionsState
234234
withAsync (periodicPollChanges genesisConfig connVar)

infra/src/Pos/Infra/Slotting/Util.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ onNewSlotDo epochSlots withLogging expectedSlotId onsp action = do
189189
shortDelay = 42
190190
recoveryRefreshDelay :: Millisecond
191191
recoveryRefreshDelay = 150
192-
logTTW timeToWait = modifyLoggerName (<> "slotting") $ logDebug $
192+
logTTW timeToWait = modifyLoggerName (<> ".slotting") $ logDebug $
193193
sformat ("Waiting for "%shown%" before new slot") timeToWait
194194

195195
logNewSlotWorker :: MonadOnNewSlot ctx m => SlotCount -> m ()
196196
logNewSlotWorker epochSlots =
197197
onNewSlotWithLogging epochSlots defaultOnNewSlotParams $ \slotId -> do
198-
modifyLoggerName (<> "slotting") $
198+
modifyLoggerName (<> ".slotting") $
199199
logNotice $ sformat ("New slot has just started: " %slotIdF) slotId
200200

201201
-- | Wait until system starts. This function is useful if node is

lib/bench/Bench/Pos/Diffusion/BlockDownload.hs

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import qualified Criterion.Main.Options as Criterion
2121
import qualified Data.ByteString.Lazy as LBS
2222
import Data.Conduit.Combinators (yieldMany)
2323
import Data.List.NonEmpty (NonEmpty ((:|)))
24-
import Data.Semigroup ((<>))
2524
import qualified Options.Applicative as Opt (execParser)
2625

2726
import qualified Network.Broadcast.OutboundQueue as OQ
@@ -124,7 +123,7 @@ withServer transport logic k = do
124123
-- Morally, the server shouldn't need an outbound queue, but we have to
125124
-- give one.
126125
oq <- liftIO $ OQ.new
127-
(wlogTrace ("server" <> "outboundqueue"))
126+
(wlogTrace ("server.outboundqueue"))
128127
Policy.defaultEnqueuePolicyRelay
129128
--Policy.defaultDequeuePolicyRelay
130129
(const (OQ.Dequeue OQ.NoRateLimiting (OQ.MaxInFlight maxBound)))
@@ -152,7 +151,7 @@ withServer transport logic k = do
152151
, fdcLastKnownBlockVersion = blockVersion
153152
, fdcConvEstablishTimeout = 15000000 -- us
154153
, fdcStreamWindow = 65536
155-
, fdcTrace = wlogTrace ("server" <> "diffusion")
154+
, fdcTrace = wlogTrace ("server.diffusion")
156155
}
157156

158157
-- Like 'withServer' but we must set up the outbound queue so that it will
@@ -167,7 +166,7 @@ withClient transport logic serverAddress@(Node.NodeId _) k = do
167166
-- Morally, the server shouldn't need an outbound queue, but we have to
168167
-- give one.
169168
oq <- OQ.new
170-
(wlogTrace ("client" <> "outboundqueue"))
169+
(wlogTrace ("client.outboundqueue"))
171170
Policy.defaultEnqueuePolicyRelay
172171
--Policy.defaultDequeuePolicyRelay
173172
(const (OQ.Dequeue OQ.NoRateLimiting (OQ.MaxInFlight maxBound)))
@@ -197,7 +196,7 @@ withClient transport logic serverAddress@(Node.NodeId _) k = do
197196
, fdcLastKnownBlockVersion = blockVersion
198197
, fdcConvEstablishTimeout = 15000000 -- us
199198
, fdcStreamWindow = 65536
200-
, fdcTrace = wlogTrace ("client" <> "diffusion")
199+
, fdcTrace = wlogTrace ("client.diffusion")
201200
}
202201

203202

lib/src/Pos/Diffusion/Full.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ diffusionLayerFull fdconf networkConfig mEkgNodeMetrics mkLogic k = do
128128
oq :: OQ.OutboundQ EnqueuedConversation NodeId Bucket <-
129129
-- NB: <> it's not Text semigroup append, it's LoggerName append, which
130130
-- puts a "." in the middle.
131-
initQueue networkConfig ("diffusion" <> "outboundqueue") (enmStore <$> mEkgNodeMetrics)
131+
initQueue networkConfig ("diffusion.outboundqueue") (enmStore <$> mEkgNodeMetrics)
132132
let topology = ncTopology networkConfig
133133
mSubscriptionWorker = topologySubscriptionWorker topology
134134
mSubscribers = topologySubscribers topology

lib/test/Test/Pos/Diffusion/BlockSpec.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ clientLogic = pureLogic
122122

123123
withServer :: Transport -> Logic IO -> (NodeId -> IO t) -> IO t
124124
withServer transport logic k = do
125-
logTrace <- liftIO $ wsetupLogging (defaultTestConfiguration Debug) ("server" <> "outboundqueue")
125+
logTrace <- liftIO $ wsetupLogging (defaultTestConfiguration Debug) ("server.outboundqueue")
126126
-- Morally, the server shouldn't need an outbound queue, but we have to
127127
-- give one.
128128
oq <- liftIO $ OQ.new
@@ -154,7 +154,7 @@ withServer transport logic k = do
154154
, fdcLastKnownBlockVersion = blockVersion
155155
, fdcConvEstablishTimeout = 15000000 -- us
156156
, fdcStreamWindow = 2048
157-
, fdcTrace = wlogTrace ("server" <> "diffusion")
157+
, fdcTrace = wlogTrace ("server.diffusion")
158158
}
159159

160160
-- Like 'withServer' but we must set up the outbound queue so that it will
@@ -170,7 +170,7 @@ withClient streamWindow transport logic serverAddress@(Node.NodeId _) k = do
170170
-- Morally, the server shouldn't need an outbound queue, but we have to
171171
-- give one.
172172
oq <- OQ.new
173-
(wlogTrace ("client" <> "outboundqueue"))
173+
(wlogTrace ("client.outboundqueue"))
174174
Policy.defaultEnqueuePolicyRelay
175175
--Policy.defaultDequeuePolicyRelay
176176
(const (OQ.Dequeue OQ.NoRateLimiting (OQ.MaxInFlight maxBound)))
@@ -200,7 +200,7 @@ withClient streamWindow transport logic serverAddress@(Node.NodeId _) k = do
200200
, fdcLastKnownBlockVersion = blockVersion
201201
, fdcConvEstablishTimeout = 15000000 -- us
202202
, fdcStreamWindow = streamWindow
203-
, fdcTrace = wlogTrace ("client" <> "diffusion")
203+
, fdcTrace = wlogTrace ("client.diffusion")
204204
}
205205

206206

networking/test/Test/NodeSpec.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import Test.Util (HeavyParcel (..), Parcel (..), Payload (..),
4646
spec :: Spec
4747
spec = describe "Node" $ modifyMaxSuccess (const 50) $ do
4848

49-
logTrace <- runIO $ wsetupLogging (defaultTestConfiguration Debug) ""
49+
logTrace <- runIO $ wsetupLogging (defaultTestConfiguration Debug) "nodespec"
5050

5151
-- Take at most 25000 bytes for each Received message.
5252
-- We want to ensure that the MTU works, but not make the tests too

util/src/Pos/Util/Log/Rotator.hs

-2
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,11 @@ cleanupRotator rotation fdesc = do
124124
removeOldFiles :: Int -> Maybe (NonEmpty FilePath) -> IO ()
125125
removeOldFiles _ Nothing = return ()
126126
removeOldFiles n (Just flist) = do
127-
putStrLn $ "dropping " ++ (show n) ++ " from " ++ (show flist)
128127
removeFiles $ reverse $ NE.drop n $ NE.reverse flist
129128
removeFiles [] = return ()
130129
removeFiles (fp : fps) = do
131130
let bp = prefixpath fdesc
132131
filepath = bp </> fp
133-
putStrLn $ "removing file " ++ filepath
134132
removeFile filepath -- destructive
135133
removeFiles fps
136134

util/src/Pos/Util/Wlog/Compatibility.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,8 @@ loggingHandler = unsafePerformIO $ do
230230
-- the backends (scribes) will be registered with katip
231231
setupLogging :: MonadIO m => LoggerConfig -> m ()
232232
setupLogging lc = liftIO $
233-
modifyMVar_ loggingHandler $ const $ Log.setupLogging lc
233+
modifyMVar_ loggingHandler $ const $ Log.setupLogging lc
234234

235-
-- LogSafe
236235

237236
-- | Whether to log to given log handler.
238237
type SelectionMode = LogSecurityLevel -> Bool

util/test/Test/Pos/Util/WlogSpec.hs

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ import Pos.Util.Wlog
1414
someLogging :: IO ()
1515
someLogging = do
1616
setupLogging loggerConfig
17+
-- context: cardano-sl.testing
1718
usingLoggerName "testing" $ do
1819
testLog
20+
-- context: cardano-sl.testing.more
21+
modifyLoggerName (<> ".more") $ do
22+
testLog
23+
-- context: cardano-sl.final
24+
modifyLoggerName (const "final") $ do
25+
testLog
1926
where
2027
loggerConfig :: LoggerConfig
2128
loggerConfig = defaultInteractiveConfiguration Debug
@@ -30,7 +37,7 @@ testLog = do
3037

3138
spec :: Spec
3239
spec = describe "Logging" $ do
33-
modifyMaxSuccess (const 2) $ modifyMaxSize (const 2) $
40+
modifyMaxSuccess (const 1) $ modifyMaxSize (const 1) $
3441
it "demonstrate logging" $
3542
monadicIO $ lift $ someLogging
3643

wallet/src/Pos/Wallet/Web/Pending/Worker.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@ startPendingTxsResubmitter genesisConfig txpConfig db submitTx =
205205
onsp
206206
(processPtxsOnSlot genesisConfig txpConfig db submitTx)
207207
where
208-
setLogger = modifyLoggerName (<> "tx" <> "resubmitter")
208+
setLogger = modifyLoggerName (<> ".tx" <> ".resubmitter")
209209
onsp :: OnNewSlotParams
210210
onsp = defaultOnNewSlotParams { onspStartImmediately = False }

0 commit comments

Comments
 (0)