From e5ac8a9c55e1e4ce3eba48324f918dfe2f368fab Mon Sep 17 00:00:00 2001 From: Manuel Date: Thu, 13 May 2021 06:28:21 +0200 Subject: [PATCH] Reduce excessive logging --- src/Myriad/Core.hs | 2 +- src/Myriad/Docker.hs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Myriad/Core.hs b/src/Myriad/Core.hs index 38fd483..7784955 100644 --- a/src/Myriad/Core.hs +++ b/src/Myriad/Core.hs @@ -95,7 +95,7 @@ initEnv configPath languagesDir = <*> newSnowflakeGen defaultConfig 0 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 args = do diff --git a/src/Myriad/Docker.hs b/src/Myriad/Docker.hs index e94b809..6450101 100644 --- a/src/Myriad/Docker.hs +++ b/src/Myriad/Docker.hs @@ -165,14 +165,14 @@ evalCode lang numRetries code = withContainer $ \cnt -> do if done -- If we find the eval is done from an exception, then it was timed out. 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 -- Otherwise, the container was killed from another eval, so we should retry. else do writeMVar doneRef True if numRetries < fromIntegral (lang ^. #retries) then do - logInfo + logDebug [ "An exception occured in " , cs cnt , ", evaluation " @@ -182,7 +182,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do ] evalCode lang (numRetries + 1) code else do - logInfo + logDebug [ "An exception occured in " , cs cnt , ", evaluation " @@ -222,7 +222,7 @@ evalCode lang numRetries code = withContainer $ \cnt -> do eval :: ContainerName -> Snowflake -> Myriad EvalResult 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, " chmod 777 eval/", show snowflake] -- 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, "`"] output <- readProcessInterleaved_ pr 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 newContainerName :: Language -> Myriad ContainerName