Reduce excessive logging

This commit is contained in:
Manuel 2021-05-13 06:28:21 +02:00
parent 6d6f6f32aa
commit e5ac8a9c55
Signed by: Manuel
GPG key ID: 4085037435E1F07A
2 changed files with 6 additions and 6 deletions

View file

@ -95,7 +95,7 @@ initEnv configPath languagesDir =
<*> newSnowflakeGen defaultConfig 0 <*> newSnowflakeGen defaultConfig 0
runMyriadT :: MonadIO m => Env -> MyriadT m a -> m a runMyriadT :: MonadIO m => Env -> MyriadT m a -> m a
runMyriadT env = runStdoutLoggingT . flip runReaderT env . unMyriadT runMyriadT env = runStdoutLoggingT . filterLogger (\_ lvl -> lvl /= LevelDebug) . flip runReaderT env . unMyriadT
exec :: (MonadIO m, MonadLogger m) => [String] -> m BL.ByteString exec :: (MonadIO m, MonadLogger m) => [String] -> m BL.ByteString
exec args = do exec args = do

View file

@ -165,14 +165,14 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
if done if done
-- If we find the eval is done from an exception, then it was timed out. -- If we find the eval is done from an exception, then it was timed out.
then do then do
logInfo ["Code timed out in container ", cs cnt, ", evaluation ", cs $ show snowflake] logDebug ["Code timed out in container ", cs cnt, ", evaluation ", cs $ show snowflake]
pure EvalTimedOut pure EvalTimedOut
-- Otherwise, the container was killed from another eval, so we should retry. -- Otherwise, the container was killed from another eval, so we should retry.
else do else do
writeMVar doneRef True writeMVar doneRef True
if numRetries < fromIntegral (lang ^. #retries) if numRetries < fromIntegral (lang ^. #retries)
then do then do
logInfo logDebug
[ "An exception occured in " [ "An exception occured in "
, cs cnt , cs cnt
, ", evaluation " , ", evaluation "
@ -182,7 +182,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
] ]
evalCode lang (numRetries + 1) code evalCode lang (numRetries + 1) code
else do else do
logInfo logDebug
[ "An exception occured in " [ "An exception occured in "
, cs cnt , cs cnt
, ", evaluation " , ", evaluation "
@ -222,7 +222,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
eval :: ContainerName -> Snowflake -> Myriad EvalResult eval :: ContainerName -> Snowflake -> Myriad EvalResult
eval cnt snowflake = do eval cnt snowflake = do
logInfo ["Running code in container ", cs cnt, ", evaluation ", cs $ show snowflake, ":\n", cs code] logDebug ["Running code in container ", cs cnt, ", evaluation ", cs $ show snowflake, ":\n", cs code]
exec_ ["docker exec ", cs cnt, " mkdir eval/", show snowflake] exec_ ["docker exec ", cs cnt, " mkdir eval/", show snowflake]
exec_ ["docker exec ", cs cnt, " chmod 777 eval/", show snowflake] exec_ ["docker exec ", cs cnt, " chmod 777 eval/", show snowflake]
-- User 1001 will be used for the actual execution so that they can't access `eval` itself -- User 1001 will be used for the actual execution so that they can't access `eval` itself
@ -239,7 +239,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do
logDebug ["Executing with stdin `", cs cmd, "`"] logDebug ["Executing with stdin `", cs cmd, "`"]
output <- readProcessInterleaved_ pr output <- readProcessInterleaved_ pr
exec_ ["docker exec ", cnt, " rm -rf eval/", show snowflake] exec_ ["docker exec ", cnt, " rm -rf eval/", show snowflake]
logInfo ["Ran code in container ", cs cnt, ", evaluation ", cs $ show snowflake] logDebug ["Ran code in container ", cs cnt, ", evaluation ", cs $ show snowflake]
pure $ EvalOk output pure $ EvalOk output
newContainerName :: Language -> Myriad ContainerName newContainerName :: Language -> Myriad ContainerName