redux-logger
redux-logger copied to clipboard
Truncate colors if not supported
This is a rehash of #203 but with different logic - 203 won't work any more due to some assumptions that the log methods were only called with max 2 parameters. This uses a lot of the same browser detection logic, with the addition of node - but has a totally different method.
In short:
-
figure out browser support ahead of time. I've got node as not supporting colors (it does, but one would need to use ansi escape sequences which aren't really compatible with html color codes)
-
proxy each of the used
consolemethods and pass arguments totruncateColorArguments- -
if colors are supported, return arguments unchanged,
-
if colors aren't supported, look for any
%cin string arguments and if found remove the number of %c found in the string from subsequent arguments - this removes the formatting information from the log.
Also, fixed the CI build... it seems that someone left backticks in ./src/core.js and eslint was complaining.
Codecov Report
:exclamation: No coverage uploaded for pull request base (
master@c8b4971). Click here to learn what that means. The diff coverage is64.51%.
@@ Coverage Diff @@
## master #279 +/- ##
=========================================
Coverage ? 78.88%
=========================================
Files ? 6
Lines ? 180
Branches ? 0
=========================================
Hits ? 142
Misses ? 38
Partials ? 0
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/core.js | 72% <0%> (ø) |
|
| src/defaults.js | 77.77% <100%> (ø) |
|
| src/logger.js | 65.51% <65.51%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update c8b4971...aa95bd4. Read the comment docs.