diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-01-31 13:11:52 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-01-31 13:11:52 +1100 |
commit | d1d4a2c05b02b0aef65f6fc9be7d7d40d75a5331 (patch) | |
tree | 782f46a5a5174a76478451fd8da5534957afa2c8 /src/Election.hs | |
parent | 678baabb7af6a45aee6199550514f97010605555 (diff) |
Improved logging/verbosity noting start/finish times and bulk exclusions
Diffstat (limited to 'src/Election.hs')
-rw-r--r-- | src/Election.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Election.hs b/src/Election.hs index a475f0e..8a0e4d0 100644 --- a/src/Election.hs +++ b/src/Election.hs @@ -80,8 +80,8 @@ data Transfer = Transfer -createElection :: FilePath -> Sen.SenateCounter -> Int -> Bool -> IO Election -createElection outDir counter numToElect verbosity = do +createElection :: FilePath -> FilePath -> Sen.SenateCounter -> Int -> Bool -> IO Election +createElection outDir mainLog counter numToElect verbosity = do entries <- mapM (candToEntry counter) (Sen.getBallot counter) return (Election { getEntries = entries @@ -89,7 +89,7 @@ createElection outDir counter numToElect verbosity = do , getLogDir = outDir , getTotalPapers = Sen.getTotal counter , getQuota = droopQuota (Sen.getTotal counter) numToElect - , getMainLog = outDir ++ "/" ++ "log.txt" + , getMainLog = mainLog , getNextLogNum = 1 , getSeats = numToElect , getVacancies = numToElect @@ -360,7 +360,14 @@ excludeCandidates e = do let v1 = v + i n1 = n + 1 if (v1 > appliedBreakpoint) - then n > 0 ? ET.left e $ ET.left r + then if (n > 0) + then do + MIO.liftIO $ Con.when (n > 1) $ do + let logmsg = "Bulk exclusion at logfile #" ++ show (getNextLogNum e) + IO.appendFile (getMainLog e) (logmsg ++ "\n") + Con.when (isVerbose e) (IO.hPutStrLn IO.stderr logmsg) + ET.left e + else ET.left r else excludeLoop n1 v1 r if (length running > 0 && all (< getQuota e) (map getTotalVotes running)) |