Compare commits

..

2 commits

Author SHA1 Message Date
Trolli Schmittlauch a2f268d374 improve logging: line buffering, time stamps
contributes to #60
2020-09-16 01:54:50 +02:00
Trolli Schmittlauch bb17b136d6 increase stabilise interval 2020-09-16 01:54:40 +02:00
2 changed files with 6 additions and 4 deletions

View file

@ -59,7 +59,7 @@ readConfig = do
, confIP = toHostAddress6 . read $ ipString
, confDhtPort = read portString
, confBootstrapNodes = confBootstrapNodes'
, confStabiliseInterval = 60 * 10^6
, confStabiliseInterval = 80 * 10^6
, confBootstrapSamplingInterval = 180 * 10^6 `div` speedup
, confMaxLookupCacheAge = 300 / fromIntegral speedup
, confJoinAttemptsInterval = 60 * 10^6 `div` speedup
@ -69,7 +69,7 @@ readConfig = do
, confRequestRetries = 3
}
sConf = ServiceConf
{ confSubscriptionExpiryTime = fromIntegral 12*3600 / fromIntegral speedup
{ confSubscriptionExpiryTime = 12*3600 / fromIntegral speedup
, confServicePort = read servicePortString
, confServiceHost = confDomainString
, confLogfilePath = "../simulationData/logs/" <> confDomainString <> ".log"

View file

@ -100,6 +100,7 @@ instance DHT d => Service PostService d where
statsQueue' <- newTQueueIO
loadStats' <- newTVarIO emptyStats
loggingFile <- openFile (confLogfilePath conf) WriteMode
hSetBuffering loggingFile LineBuffering
let
thisService = PostService
{ serviceConf = conf
@ -121,7 +122,7 @@ instance DHT d => Service PostService d where
-- log a start message, this also truncates existing files
TxtI.hPutStrLn loggingFile $ Txt.unlines
[ "# Starting mock relay implementation"
, "#relay receive rate ;relay delivery rate ;instance publish rate ;instance fetch rate ;total subscriptions"
, "#time stamp ; relay receive rate ;relay delivery rate ;instance publish rate ;instance fetch rate ;total subscriptions"
]
-- Run 'concurrently_' from another thread to be able to return the
-- 'PostService'.
@ -841,7 +842,8 @@ evaluateStatsThread serv statsAcc = getPOSIXTime >>= loop
-- later: current (reported) load, target load
subscriberSum <- sumSubscribers
TxtI.hPutStrLn (logFileHandle serv) $
format (fixed 20 % ";" % fixed 20 % ";" % fixed 20 % ";" % fixed 20 % ";" % int )
format (fixed 9 % ";" % fixed 20 % ";" % fixed 20 % ";" % fixed 20 % ";" % fixed 20 % ";" % int )
(realToFrac now :: Double)
(sum . relayReceiveRates $ rateStats)
(sum . relayDeliveryRates $ rateStats)
(postPublishRate rateStats)