added a commit to mpilgrem/rio-prettyprint that referenced this pull request
Aug 1, 2020Add styles `Info`, `Debug`, `OtherLevel`, `Secondary` and `Highlight` to type `Style`, that correspond to: (1) constructors of `RIO.Prelude.Logger.LogLevel` not currently catered for, namely `LevelInfo`, `LevelDebug` and `LevelOther !Text`. These constructors determine styles (currently hard-coded) used by `RIO.Prelude.Logger.simpleLogFunc`; and (2) styles (currently hard-coded) used by `RIO.Prelude.Logger.simpleLogFunc` (for timestamps and locs, treated as secondary content) and `RIO.Process.withProcessTimeLog` (to highlight process duration). The defaults for the additons, in `RIO.PrettyPrint.DefaultStyles`, are the hard-coded styles used in `RIO.Prelude.Logger.simpleLogFunc` and `RIO.Process.withProcessTimeLog`. The additions do not change the order of the existing constructors of `Style`. Code documentation for the new styles is included and the code document for existing styles is extended or tidied-up. The motivation for these changes is explained in commercialhaskell/rio#222.
Merged
Closed
The motivation for this is that the exisitng hard-coded colours in `RIO.Process.withProcessTimeLog` and `RIO.Prelude.Logger.simpleLogFunc` (for timestamps and locs) are not visible when using the Solarised Dark theme.
Tested on Windows 10 by sucessfully rebuilding `stack` (which depends on `rio`), with and without making use of the option to customise logger colours.
The defaults are the same as what was previously hard-coded, so existing code depending on `rio` should not be affected.
A new `LogColors` type is defined but not exported, and three associated accessors are exported (`logFuncLogLevelColorsL`, `logFuncSecondaryColorL` and `logFuncAccentColorsL`):
```haskell
data LogColors = LogColors
{ -- | The color associated with each 'LogLevel'.
logColorLogLevels :: !(LogLevel -> Utf8Builder)
-- | The color of secondary content.
, logColorSecondary :: !Utf8Builder
-- | The color of accents, which are indexed by 'Int'.
, logColorAccents :: !(Int -> Utf8Builder)
}
```
timestamps and locs in `simpleLogFunc` use the colour of secondary content. `withProcessTimeLog` uses accent colour 0 to highlight the duration time.
mpilgrem added a commit to mpilgrem/rio-prettyprint that referenced this pull request
Aug 3, 2020Add styles `Info`, `Debug`, `OtherLevel`, `Secondary` and `Highlight` to type `Style`, that correspond to: (1) constructors of `RIO.Prelude.Logger.LogLevel` not currently catered for, namely `LevelInfo`, `LevelDebug` and `LevelOther !Text`. These constructors determine styles (currently hard-coded) used by `RIO.Prelude.Logger.simpleLogFunc`; and (2) styles (currently hard-coded) used by `RIO.Prelude.Logger.simpleLogFunc` (for timestamps and locs, treated as secondary content) and `RIO.Process.withProcessTimeLog` (to highlight process duration). The defaults for the additons, in `RIO.PrettyPrint.DefaultStyles`, are the hard-coded styles used in `RIO.Prelude.Logger.simpleLogFunc` and `RIO.Process.withProcessTimeLog`. The additions do not change the order of the existing constructors of `Style`. Code documentation for the new styles is included and the code document for existing styles is extended or tidied-up. The motivation for these changes is explained in commercialhaskell/rio#222.