-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add colours to the LogOption
constructor
#222
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpilgrem
added a commit
to mpilgrem/rio-prettyprint
that referenced
this pull request
Aug 1, 2020
Add 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.
Since my original pull request, I have changed the type in the three |
snoyberg
reviewed
Aug 3, 2020
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, 2020
Add 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.
snoyberg
approved these changes
Aug 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The motivation for this pull request is that the exisitng hard-coded colours in
RIO.Process.withProcessTimeLog
andRIO.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 onrio
), with and without making use of the option to customise logger colours.The defaults are the same as what was previously hard-coded and
RIO.Prelude.Logger
does not export the constructor ofLogOption
, so existing code depending onrio
should not be affected.A new
LogColors
type is exported, and an associated accessor (logFuncColorsL
):timestamps and locs in
simpleLogFunc
use the colour of secondary content.withProcessTimeLog
uses accent colour 0 to highlight the duration time.