aboutsummaryrefslogtreecommitdiff
path: root/lib/Distribution
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-01-30 20:59:12 +0100
committerDaniel Gröber <dxld@darkboxed.org>2019-01-30 20:59:12 +0100
commitbf9e458fd74a9d187be6929c212e46b341b05c8c (patch)
tree2f6d84dcf750603cd51cea2660036d54da17caab /lib/Distribution
parent74704110ca0eb6760a6e133ac88133a590d4ef8f (diff)
Add log-level to verbosity conditional
Diffstat (limited to 'lib/Distribution')
-rw-r--r--lib/Distribution/Helper.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs
index ca5c1b1..95547c3 100644
--- a/lib/Distribution/Helper.hs
+++ b/lib/Distribution/Helper.hs
@@ -119,6 +119,7 @@ import System.Process
import System.Posix.Types
import System.PosixCompat.Files
import Text.Printf
+import Text.Read
import Prelude
import CabalHelper.Compiletime.Compile
@@ -140,7 +141,7 @@ import qualified CabalHelper.Compiletime.Compat.ProgramDb as ProgDb
import Distribution.System (buildPlatform)
import Distribution.Text (display)
-import Distribution.Verbosity (silent, deafening)
+import Distribution.Verbosity (silent, normal, verbose, deafening)
import Distribution.Simple.GHC as GHC (configure)
-- $type-conventions
@@ -189,7 +190,8 @@ mkQueryEnv projloc distdir = do
{ qeReadProcess = \stdin mcwd exe args ->
readCreateProcess (proc exe args){ cwd = mcwd } stdin
, qeCallProcess = \mcwd exe args -> do
- let ?verbose = False -- TODO: we should get this from env or something
+ let ?verbose = \_ -> False -- TODO: we should get this from env or
+ -- something
callProcessStderr mcwd exe args
, qePrograms = defaultPrograms
, qeCompPrograms = defaultCompPrograms
@@ -569,9 +571,9 @@ lookupEnv' k = lookup k <$> getEnvironment
withVerbosity :: (Verbose => IO a) -> IO a
withVerbosity act = do
x <- lookup "CABAL_HELPER_DEBUG" <$> getEnvironment
- let ?verbose =
- case x of
- Just xs | not (null xs) -> True
+ let ?verbose = \level ->
+ case x >>= readMaybe of
+ Just x | x >= level -> True
_ -> False
act
@@ -591,7 +593,9 @@ withProgs impl QueryEnv{..} f = do
guessCompProgramPaths progs
| same ghcProgram progs dprogs = return progs
guessCompProgramPaths progs = do
- let v | ?verbose = deafening
+ let v | ?verbose 2 = normal
+ | ?verbose 3 = verbose
+ | ?verbose 4 = deafening
| otherwise = silent
mGhcPath0 | same ghcProgram progs dprogs = Nothing
| otherwise = Just $ ghcProgram progs