From 32702fce65b0d064b958aac9b32b9cd5f845d19b Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Oct 2023 08:09:00 +0300 Subject: [PATCH 1/9] rm Log from Severity loglevels --- cabal-install/src/Distribution/Client/Init/Types.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal-install/src/Distribution/Client/Init/Types.hs b/cabal-install/src/Distribution/Client/Init/Types.hs index 41513d0f048..3657f0a2755 100644 --- a/cabal-install/src/Distribution/Client/Init/Types.hs +++ b/cabal-install/src/Distribution/Client/Init/Types.hs @@ -455,7 +455,7 @@ 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, Show) -- | Convenience alias for the literate haskell flag type IsLiterate = Bool From 9e4817920049bff5df73b62e85b73e948c900325 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Oct 2023 08:23:37 +0300 Subject: [PATCH 2/9] replace Log with Info --- .../src/Distribution/Client/Init/FileCreators.hs | 10 +++++----- cabal-install/src/Distribution/Client/Init/Utils.hs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cabal-install/src/Distribution/Client/Init/FileCreators.hs b/cabal-install/src/Distribution/Client/Init/FileCreators.hs index 18ea0bc71a1..f53ce7a6e53 100644 --- a/cabal-install/src/Distribution/Client/Init/FileCreators.hs +++ b/cabal-install/src/Distribution/Client/Init/FileCreators.hs @@ -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) @@ -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 @@ -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 " @@ -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 @@ -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 " diff --git a/cabal-install/src/Distribution/Client/Init/Utils.hs b/cabal-install/src/Distribution/Client/Init/Utils.hs index e8cde1184ae..f986cce0e03 100644 --- a/cabal-install/src/Distribution/Client/Init/Utils.hs +++ b/cabal-install/src/Distribution/Client/Init/Utils.hs @@ -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, From 1eed4beab5fd9eeec8d1ed4c7e3ba3b1592fa42e Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Oct 2023 08:30:22 +0300 Subject: [PATCH 3/9] add changelog --- changelog.d/pr-9346 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 changelog.d/pr-9346 diff --git a/changelog.d/pr-9346 b/changelog.d/pr-9346 new file mode 100644 index 00000000000..a94b865e7e7 --- /dev/null +++ b/changelog.d/pr-9346 @@ -0,0 +1,13 @@ +synopsis: remove +packages: cabal-install +prs: #9346 +issues: #9151 +significance: minor + +description: { + +- Log is used in cabal-install as a loglevel. +- "Log" is not a (loglevel)[https://betterstack.com/community/guides/logging/log-levels-explained/]. +- replace Log with Info where it is used. + +} From 3cb40662875c38320de6e1185efea26fe2a32e0b Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Oct 2023 08:33:32 +0300 Subject: [PATCH 4/9] fix typo --- changelog.d/pr-9346 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/pr-9346 b/changelog.d/pr-9346 index a94b865e7e7..3df77de8f9f 100644 --- a/changelog.d/pr-9346 +++ b/changelog.d/pr-9346 @@ -7,7 +7,7 @@ significance: minor description: { - Log is used in cabal-install as a loglevel. -- "Log" is not a (loglevel)[https://betterstack.com/community/guides/logging/log-levels-explained/]. +- "Log" is not a [loglevel](https://betterstack.com/community/guides/logging/log-levels-explained/). - replace Log with Info where it is used. } From 711ad2afae8589e353ce089a3ef856d0a7096449 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Oct 2023 08:56:40 +0300 Subject: [PATCH 5/9] fix changelog entry --- changelog.d/pr-9346 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/pr-9346 b/changelog.d/pr-9346 index 3df77de8f9f..42ca8d301de 100644 --- a/changelog.d/pr-9346 +++ b/changelog.d/pr-9346 @@ -2,7 +2,7 @@ synopsis: remove packages: cabal-install prs: #9346 issues: #9151 -significance: minor +significance: significant description: { From 415908b5f740fbd70b09730996ad80d4b4ce04a0 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Oct 2023 08:33:53 +0300 Subject: [PATCH 6/9] add displaySeverity --- cabal-install/src/Distribution/Client/Init/Types.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cabal-install/src/Distribution/Client/Init/Types.hs b/cabal-install/src/Distribution/Client/Init/Types.hs index 3657f0a2755..7252b37e393 100644 --- a/cabal-install/src/Distribution/Client/Init/Types.hs +++ b/cabal-install/src/Distribution/Client/Init/Types.hs @@ -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 @@ -407,7 +407,7 @@ instance Interactive PurePrompt where Error -> PurePrompt $ \_ -> Left $ BreakException - (show severity ++ ": " ++ msg) + (displaySeverity severity ++ ": " ++ msg) _ -> return () break = return True @@ -455,7 +455,12 @@ newtype BreakException = BreakException String deriving (Eq, Show) instance Exception BreakException -- | Used to inform the intent of prompted messages. -data Severity = Info | Warning | Error deriving (Eq, Show) +data Severity = Info | Warning | Error deriving (Eq) + +displaySeverity :: Severity -> String +displaySeverity severity | severity == Info = "Info" + | severity == Warning = "Warn" + | severity == Error = "Err" -- | Convenience alias for the literate haskell flag type IsLiterate = Bool From 07d3fa5ea9866f217208bed4fa1f1b29eb09efd2 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Oct 2023 08:42:19 +0300 Subject: [PATCH 7/9] fix changelog --- changelog.d/pr-9346 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/changelog.d/pr-9346 b/changelog.d/pr-9346 index 42ca8d301de..3f31da43837 100644 --- a/changelog.d/pr-9346 +++ b/changelog.d/pr-9346 @@ -6,8 +6,7 @@ significance: significant description: { -- Log is used in cabal-install as a loglevel. -- "Log" is not a [loglevel](https://betterstack.com/community/guides/logging/log-levels-explained/). -- replace Log with Info where it is used. +- Remove "Log" as a log level in favour of "Info". +- Remove "Show" in Severity and replace by "displaySeverity" function } From 988b0bbe1409c664996019bbd108f473518c1f92 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Oct 2023 08:44:02 +0300 Subject: [PATCH 8/9] run fourmolu --- cabal-install/src/Distribution/Client/Init/Types.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cabal-install/src/Distribution/Client/Init/Types.hs b/cabal-install/src/Distribution/Client/Init/Types.hs index 7252b37e393..5c10b2fde42 100644 --- a/cabal-install/src/Distribution/Client/Init/Types.hs +++ b/cabal-install/src/Distribution/Client/Init/Types.hs @@ -458,9 +458,10 @@ instance Exception BreakException data Severity = Info | Warning | Error deriving (Eq) displaySeverity :: Severity -> String -displaySeverity severity | severity == Info = "Info" - | severity == Warning = "Warn" - | severity == Error = "Err" +displaySeverity severity + | severity == Info = "Info" + | severity == Warning = "Warn" + | severity == Error = "Err" -- | Convenience alias for the literate haskell flag type IsLiterate = Bool From 726f8d9e227ff7868abcafc99ca9541ab62f1591 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Oct 2023 18:59:17 +0300 Subject: [PATCH 9/9] implement case expression in displaySeverity --- cabal-install/src/Distribution/Client/Init/Types.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cabal-install/src/Distribution/Client/Init/Types.hs b/cabal-install/src/Distribution/Client/Init/Types.hs index 5c10b2fde42..ee7d7cbe0c3 100644 --- a/cabal-install/src/Distribution/Client/Init/Types.hs +++ b/cabal-install/src/Distribution/Client/Init/Types.hs @@ -458,10 +458,10 @@ instance Exception BreakException data Severity = Info | Warning | Error deriving (Eq) displaySeverity :: Severity -> String -displaySeverity severity - | severity == Info = "Info" - | severity == Warning = "Warn" - | severity == Error = "Err" +displaySeverity severity = case severity of + Info -> "Info" + Warning -> "Warn" + Error -> "Err" -- | Convenience alias for the literate haskell flag type IsLiterate = Bool