Add setLoggerReformat #62
Merged
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.
This refactors the contract between
reformatTerminal
and theconstruction that happens in
newLogger
.Previously, we constructed
lReformat
directly, which is a function ofonly
LogLevel
andByteString
. This meant that a "reformat" functionsuch as
reformatTerminal
had to do some extra work that all suchfunctions would have to do:
Colors
value if neededByteString
as-is if it doesn't parse asLoggedMessage
We can pull both of these responsibilities out into
newLogger
itselfand simplify
reformatTerminal
by giving it what it needs directly.Also, by passing
LogSettings
entirely (instead of just thebreakpoint), we've now made its signature into something that works well
as a generic "reformat" interface.
Then, by putting that logic behind a
setLoggerReformat
thatnewLogger
uses internally, we give users a hook for assign any such"reformat" function from the outside too:
An extension like this doesn't interact with
LOG_FORMAT
, which may besurprising, but it works well for situations that don't need to be
runtime-dynamic like that, such as CLIs.