log: replace homegrown coloring code
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:
- the new code should abstract the color numeric codes into symbolic names
- it must test the right file descriptor (
stderr, notstdout) - 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.
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 great! I'm happy to mentor and review your work (reach out to me on our gitter channel if you need help).
Welcome!
I can take a stab at this if it's alright for a first time contributor.
Please do!
I'll get right on it.
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 welcome! Our dependency management workflow is described here.
If you have additional questions, let's discuss in #15587. Thanks!
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.
Is this task still applicable?
It is still applicable but please check the requirements!
Addressed in #26936.