@@ -169,6 +169,8 @@ module Stack.Types.Config
169169 ,envOverrideSettingsL
170170 ,shouldForceGhcColorFlag
171171 ,appropriateGhcColorFlag
172+ -- * Helper logging functions
173+ ,prettyStackDevL
172174 -- * Lens reexport
173175 ,view
174176 ,to
@@ -214,7 +216,7 @@ import Pantry.Internal (Storage)
214216import Path
215217import qualified Paths_stack as Meta
216218import qualified RIO.List as List
217- import RIO.PrettyPrint (HasTerm (.. ))
219+ import RIO.PrettyPrint (HasTerm (.. ), StyleDoc , prettyWarnL , prettyDebugL )
218220import RIO.PrettyPrint.StylesUpdate (StylesUpdate ,
219221 parseStylesUpdateFromString , HasStylesUpdate (.. ))
220222import Stack.Constants
@@ -377,6 +379,8 @@ data Config =
377379 -- ^ Enable GHC hiding source paths?
378380 ,configRecommendUpgrade :: ! Bool
379381 -- ^ Recommend a Stack upgrade?
382+ ,configStackDeveloperMode :: ! Bool
383+ -- ^ Turn on Stack developer mode for additional messages?
380384 }
381385
382386-- | A bit of type safety to ensure we're talking to the right database.
@@ -859,6 +863,8 @@ data ConfigMonoid =
859863 , configMonoidRecommendUpgrade :: ! FirstTrue
860864 -- ^ See 'configRecommendUpgrade'
861865 , configMonoidCasaRepoPrefix :: ! (First CasaRepoPrefix )
866+ , configMonoidStackDeveloperMode :: ! (First Bool )
867+ -- ^ See 'configStackDeveloperMode'
862868 }
863869 deriving (Show , Generic )
864870
@@ -983,6 +989,8 @@ parseConfigMonoidObject rootDir obj = do
983989
984990 configMonoidCasaRepoPrefix <- First <$> obj ..:? configMonoidCasaRepoPrefixName
985991
992+ configMonoidStackDeveloperMode <- First <$> obj ..:? configMonoidStackDeveloperModeName
993+
986994 return ConfigMonoid {.. }
987995 where
988996 handleExplicitSetupDep :: (Monad m , MonadFail m ) => (Text , Bool ) -> m (Maybe PackageName , Bool )
@@ -1148,6 +1156,9 @@ configMonoidRecommendUpgradeName = "recommend-stack-upgrade"
11481156configMonoidCasaRepoPrefixName :: Text
11491157configMonoidCasaRepoPrefixName = " casa-repo-prefix"
11501158
1159+ configMonoidStackDeveloperModeName :: Text
1160+ configMonoidStackDeveloperModeName = " stack-developer-mode"
1161+
11511162data ConfigException
11521163 = ParseConfigFileException (Path Abs File ) ParseException
11531164 | ParseCustomSnapshotException Text ParseException
@@ -2126,3 +2137,11 @@ terminalL = globalOptsL.lens globalTerminal (\x y -> x { globalTerminal = y })
21262137-- | See 'globalReExecVersion'
21272138reExecL :: HasRunner env => SimpleGetter env Bool
21282139reExecL = globalOptsL. to (isJust . globalReExecVersion)
2140+
2141+ -- | In dev mode, print as a warning, otherwise as debug
2142+ prettyStackDevL :: HasConfig env => [StyleDoc ] -> RIO env ()
2143+ prettyStackDevL docs = do
2144+ config <- view configL
2145+ if configStackDeveloperMode config
2146+ then prettyWarnL docs
2147+ else prettyDebugL docs
0 commit comments