logging-effect-colors 0.1.0.0 → 0.1.1.1
raw patch · 3 files changed
+70/−31 lines, 3 filesdep ~ansi-terminaldep ~textPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ansi-terminal, text
API changes (from Hackage documentation)
+ Control.Monad.Log.Colors: Reset :: SGR
+ Control.Monad.Log.Colors: SetBlinkSpeed :: !BlinkSpeed -> SGR
+ Control.Monad.Log.Colors: SetColor :: !ConsoleLayer -> !ColorIntensity -> !Color -> SGR
+ Control.Monad.Log.Colors: SetConsoleIntensity :: !ConsoleIntensity -> SGR
+ Control.Monad.Log.Colors: SetDefaultColor :: !ConsoleLayer -> SGR
+ Control.Monad.Log.Colors: SetItalicized :: !Bool -> SGR
+ Control.Monad.Log.Colors: SetPaletteColor :: !ConsoleLayer -> !Word8 -> SGR
+ Control.Monad.Log.Colors: SetRGBColor :: !ConsoleLayer -> !Colour Float -> SGR
+ Control.Monad.Log.Colors: SetSwapForegroundBackground :: !Bool -> SGR
+ Control.Monad.Log.Colors: SetUnderlining :: !Underlining -> SGR
+ Control.Monad.Log.Colors: SetVisible :: !Bool -> SGR
+ Control.Monad.Log.Colors: alert :: [SGR]
+ Control.Monad.Log.Colors: critical :: [SGR]
+ Control.Monad.Log.Colors: data SGR
+ Control.Monad.Log.Colors: debug :: [SGR]
+ Control.Monad.Log.Colors: emergency :: [SGR]
+ Control.Monad.Log.Colors: err :: [SGR]
+ Control.Monad.Log.Colors: info :: [SGR]
+ Control.Monad.Log.Colors: notice :: [SGR]
+ Control.Monad.Log.Colors: trace :: [SGR]
+ Control.Monad.Log.Colors: warning :: [SGR]
Files
- CHANGELOG.md +8/−0
- logging-effect-colors.cabal +3/−3
- src/Control/Monad/Log/Colors.hs +59/−28
CHANGELOG.md view
@@ -1,5 +1,13 @@ # Revision history for logging-effect-colors +## 0.1.1.1++* Update dependency version bounds++## 0.1.1.0++* Export SGR codes for log severity levels+ ## 0.1.0.0 * Provides `colorize`, `colorizeWith`, and `renderWithColor`.
logging-effect-colors.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: logging-effect-colors-version: 0.1.0.0+version: 0.1.1.1 synopsis: Log messages in color description: ANSI color coding for logging-effect log messages homepage: https://github.com/obsidiansystems/logging-effect-colors@@ -21,11 +21,11 @@ library exposed-modules: Control.Monad.Log.Colors build-depends:- ansi-terminal >=0.9 && <1.1+ ansi-terminal >=0.9 && <1.2 , base >= 4.12 && < 5 , logging-effect >=1.3 && <1.5 , prettyprinter >=1.2 && <1.8- , text >=1.2 && <2.1+ , text >=1.2 && <2.2 hs-source-dirs: src default-language: Haskell2010
src/Control/Monad/Log/Colors.hs view
@@ -1,5 +1,22 @@ {-# options_ghc -Wall #-}-module Control.Monad.Log.Colors where+module Control.Monad.Log.Colors+ ( wrapSGRCode+ , emergency+ , alert+ , critical+ , err+ , warning+ , notice+ , info+ , debug+ , trace+ , severitySgr+ , colorizeWith+ , colorize+ , renderWithColor+ , SGR(..)+ )+ where import Control.Monad.Log import Data.String@@ -15,35 +32,49 @@ , fromString $ setSGRCode [Reset] ] +emergency, alert, critical, err, warning, notice, info, debug, trace :: [SGR]+emergency =+ [ SetColor Background Vivid Red+ , SetColor Foreground Vivid Black+ , SetConsoleIntensity BoldIntensity+ ]+alert =+ [ SetColor Foreground Vivid Red+ , SetConsoleIntensity BoldIntensity+ ]+critical =+ [ SetColor Foreground Vivid Red+ , SetConsoleIntensity BoldIntensity+ ]+err =+ [ SetColor Foreground Dull Red+ ]+warning =+ [ SetColor Foreground Vivid Yellow+ ]+notice =+ [ SetColor Foreground Vivid Blue+ ]+info =+ []+debug =+ [ SetColor Foreground Dull Green+ ]+trace =+ [ SetColor Foreground Dull White+ ]+ -- | Mapping of 'Severity' levels to SGR styles severitySgr :: Severity -> [SGR] severitySgr = \case- Emergency ->- [ SetColor Background Vivid Red- , SetColor Foreground Vivid Black- , SetConsoleIntensity BoldIntensity- ]- Alert ->- [ SetColor Foreground Vivid Red- , SetConsoleIntensity BoldIntensity- ]- Critical ->- [ SetColor Foreground Vivid Red- , SetConsoleIntensity BoldIntensity- ]- Error ->- [ SetColor Foreground Dull Red- ]- Warning ->- [ SetColor Foreground Vivid Yellow- ]- Notice ->- [ SetColor Foreground Vivid Blue- ]- Informational -> []- Debug -> - [ SetColor Foreground Dull Green- ]+ Emergency -> emergency+ Alert -> alert+ Critical -> critical+ Error -> err+ Warning -> warning+ Notice -> notice+ Informational -> info+ Debug -> debug -- | Color based on severity with a custom mapping of severity to SGR styles colorizeWith@@ -55,7 +86,7 @@ WithSeverity sev $ wrapSGRCode (f sev) msg -- | Color based on severity with the default mapping of severity to SGR styles-colorize +colorize :: (Monoid msg, IsString msg) => WithSeverity msg -> WithSeverity msg