From 62005f83a4a362fe2bc13654421843b86151960e Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 17 Apr 2020 17:12:59 +0200 Subject: [PATCH] Improve debug info --- app/ghcup/Main.hs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index ed9e575..38e4986 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -750,7 +750,7 @@ Check the logs at ~/.ghcup/logs and the build directory #{tmpdir} for more clues liftE $ getDebugInfo ) >>= \case - VRight dinfo -> putStrLn $ show dinfo + VRight dinfo -> putStrLn $ prettyDebugInfo dinfo VLeft e -> runLogger ($(logError) [i|#{e}|]) >> exitFailure @@ -891,3 +891,24 @@ checkForUpdates dls = do when (l > ghc_ver) $ $(logWarn) [i|New GHCup version available: #{prettyVer l}. To upgrade, run 'ghcup upgrade'|] + + +prettyDebugInfo :: DebugInfo -> String +prettyDebugInfo DebugInfo {..} = [i|Debug Info +========== +GHCup base dir: #{toFilePath diBaseDir} +GHCup bin dir: #{toFilePath diBinDir} +GHCup GHC directory: #{toFilePath diGHCDir} +GHCup cache directory: #{toFilePath diCacheDir} +Architecture: #{prettyArch diArch} +Platform: #{prettyPlatform diPlatform} +Version: #{describe_result}|] + where + prettyArch :: Architecture -> String + prettyArch A_64 = "amd64" + prettyArch A_32 = "i386" + prettyPlatform :: PlatformResult -> String + prettyPlatform PlatformResult { _platform = plat, _distroVersion = Just v' } + = show plat <> ", " <> show v' + prettyPlatform PlatformResult { _platform = plat, _distroVersion = Nothing } + = show plat