cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

log: replace homegrown coloring code

Open tamird opened this issue 9 years ago • 11 comments

This should be a self-contained task, touching only the logging package.

Related to #14483.

Good one for a first-time contributor.

The code in question: https://github.com/cockroachdb/cockroach/blob/34736b8e24aa242d80ca890cf8b3d0fe1fa4763e/pkg/util/log/clog.go#L788:L823 plus surrounding types.

Three requirements:

  1. the new code should abstract the color numeric codes into symbolic names
  2. it must test the right file descriptor (stderr, not stdout)
  3. it must be conservative about which color codes are sent to which terminal type. Not every terminal supports the same colors.

For example the package at http://github.com/faith/color does not satisfy requirements 2 and 3.

tamird avatar Apr 05 '17 16:04 tamird

I can work with this one. This will be my first time contributing to this awesome project.

I was looking at the source code of the logging package and it seems like an easy task. I was worried for github.com/faith/color Windows support but I just saw that the latest version now correctly supports it so I hope it does not be too hard

juanjcsr avatar Apr 06 '17 15:04 juanjcsr

@juanjcsr great! I'm happy to mentor and review your work (reach out to me on our gitter channel if you need help).

Welcome!

tamird avatar Apr 06 '17 15:04 tamird

I can take a stab at this if it's alright for a first time contributor.

MattBroyles avatar Apr 25 '17 02:04 MattBroyles

Please do!

tamird avatar Apr 25 '17 02:04 tamird

I'll get right on it.

MattBroyles avatar Apr 25 '17 02:04 MattBroyles

Hi, tamird, I have replace homegrown coloring code with https://github.com/fatih/color .. In this case, I need to add the open project "github.com/mattn/go-colorable" to "cockroachdb/cockroach/vendor" . so I copy "github.com/mattn/go-colorable" to the path "cockroachdb/cockroach/vendor". I write a test function to check the output and It runs OK . But , I still doubt wether it will take effect after it has been merged . How do you mange the open project ? If I need add a new one, what shoud I do ?

yangliang9004 avatar May 02 '17 03:05 yangliang9004

@yangliang9004 welcome! Our dependency management workflow is described here.

If you have additional questions, let's discuss in #15587. Thanks!

tamird avatar May 02 '17 11:05 tamird

I have added more details about the requirements in the original issue description here: https://github.com/cockroachdb/cockroach/issues/14634#issue-219646919

This highlights that https://github.com/fatih/color is probably not the right package to use, without further changes.

knz avatar May 02 '17 14:05 knz

Is this task still applicable?

Ngo-The-Trung avatar Jul 31 '17 14:07 Ngo-The-Trung

It is still applicable but please check the requirements!

knz avatar Jul 31 '17 14:07 knz

Addressed in #26936.

knz avatar Jul 09 '18 15:07 knz