Skip to content
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

Truncate colors if not supported #279

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tswaters
Copy link

@tswaters tswaters commented Dec 20, 2017

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.

@codecov-io
Copy link

codecov-io commented Dec 20, 2017

Codecov Report

❗ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants