Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9151 (cabal init logs at loglevel "Log") #9346

Merged
merged 9 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cabal-install/src/Distribution/Client/Init/FileCreators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ writeProject (ProjectSettings opts pkgDesc libTarget exeTarget testTarget)
message opts T.Error "no package name given, so no .cabal file can be generated\n"
| otherwise = do
-- clear prompt history a bit"
message opts T.Log $
message opts T.Info $
"Using cabal specification: "
++ showCabalSpecVersion (_optCabalSpec opts)

Expand Down Expand Up @@ -269,7 +269,7 @@ writeFileSafe opts fileName content = do

go exists

message opts T.Log $ show action ++ " file " ++ fileName ++ "..."
message opts T.Info $ show action ++ " file " ++ fileName ++ "..."
return $ action == Existing
where
doOverwrite = _optOverwrite opts
Expand All @@ -279,7 +279,7 @@ writeFileSafe opts fileName content = do
writeFile fileName content
| exists && doOverwrite = do
newName <- findNewPath fileName
message opts T.Log $
message opts T.Info $
concat
[ fileName
, " already exists. Backing up old version in "
Expand All @@ -302,7 +302,7 @@ writeDirectoriesSafe opts dirs = fmap or $ for dirs $ \dir -> do

go dir exists

message opts T.Log $ show action ++ " directory ./" ++ dir ++ "..."
message opts T.Info $ show action ++ " directory ./" ++ dir ++ "..."
return $ action == Existing
where
doOverwrite = _optOverwrite opts
Expand All @@ -312,7 +312,7 @@ writeDirectoriesSafe opts dirs = fmap or $ for dirs $ \dir -> do
createDirectory dir
| exists && doOverwrite = do
newDir <- findNewPath dir
message opts T.Log $
message opts T.Info $
concat
[ dir
, " already exists. Backing up old version in "
Expand Down
12 changes: 9 additions & 3 deletions cabal-install/src/Distribution/Client/Init/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ instance Interactive IO where
hFlush = System.IO.hFlush
message q severity msg
| q == silent = pure ()
| otherwise = putStrLn $ "[" ++ show severity ++ "] " ++ msg
| otherwise = putStrLn $ "[" ++ displaySeverity severity ++ "] " ++ msg
break = return False
throwPrompt = throwM

Expand Down Expand Up @@ -407,7 +407,7 @@ instance Interactive PurePrompt where
Error -> PurePrompt $ \_ ->
Left $
BreakException
(show severity ++ ": " ++ msg)
(displaySeverity severity ++ ": " ++ msg)
_ -> return ()

break = return True
Expand Down Expand Up @@ -455,7 +455,13 @@ newtype BreakException = BreakException String deriving (Eq, Show)
instance Exception BreakException

-- | Used to inform the intent of prompted messages.
data Severity = Log | Info | Warning | Error deriving (Eq, Show)
data Severity = Info | Warning | Error deriving (Eq)

displaySeverity :: Severity -> String
aleeusgr marked this conversation as resolved.
Show resolved Hide resolved
displaySeverity severity = case severity of
Info -> "Info"
Warning -> "Warn"
Error -> "Err"

-- | Convenience alias for the literate haskell flag
type IsLiterate = Bool
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/Init/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ retrieveDependencies v flags mods' pkgIx = do
modDeps = map (\(mn, ds) -> (mn, ds, M.lookup ds modMap)) mods
-- modDeps = map (id &&& flip M.lookup modMap) mods

message v Log "Guessing dependencies..."
message v Info "Guessing dependencies..."
nub . catMaybes <$> traverse (chooseDep v flags) modDeps

-- Given a module and a list of installed packages providing it,
Expand Down
12 changes: 12 additions & 0 deletions changelog.d/pr-9346
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
synopsis: remove
packages: cabal-install
prs: #9346
issues: #9151
significance: significant

description: {

- Remove "Log" as a log level in favour of "Info".
- Remove "Show" in Severity and replace by "displaySeverity" function

}
Loading