redux-logger icon indicating copy to clipboard operation
redux-logger copied to clipboard

Truncate colors if not supported

Open tswaters opened this issue 7 years ago • 1 comments

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 console methods and pass arguments to truncateColorArguments -

  • if colors are supported, return arguments unchanged,

  • if colors aren't supported, look for any %c in 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.

tswaters avatar Dec 20 '17 23:12 tswaters

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@c8b4971). Click here to learn what that means. The diff coverage is 64.51%.

Impacted file tree graph

@@            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 data Powered by Codecov. Last update c8b4971...aa95bd4. Read the comment docs.

codecov-io avatar Dec 20 '17 23:12 codecov-io