Skip to content
Myr

Make logger use a yellow background and a darkgray text for legibility (#1570)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

1. Why is this change neccesary? White text on a yellow background was illegible with most terminal color schemes 2. How does it address the issue? The white text was replaced with a bash compatible dark gray while keeping the yellow background colour 3. What side effects does this change have? Resolves #1552

authored by andrea · committed by 田欧 · parent b02e4f2 · Browse files · 2 files+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−3 removed

  • other:+3 added−3 removed

2 files+3 added−3 removed

modified:logger_test.go+2 added-2 removed
83 unmodified lines
8485func TestColorForMethod(t *testing.T) {86 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 52, 109}), colorForMethod("GET"), "get should be blue")87 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 54, 109}), colorForMethod("POST"), "post should be cyan")88 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 51, 109}), colorForMethod("PUT"), "put should be yellow")88 assert.Equal(t, string([]byte{27, 91, 57, 48, 59, 52, 51, 109}), colorForMethod("PUT"), "put should be yellow")89 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 49, 109}), colorForMethod("DELETE"), "delete should be red")90 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 50, 109}), colorForMethod("PATCH"), "patch should be green")91 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 53, 109}), colorForMethod("HEAD"), "head should be magenta")92 assert.Equal(t, string([]byte{27, 91, 57, 48, 59, 52, 55, 109}), colorForMethod("OPTIONS"), "options should be white")
2 unmodified lines
9596func TestColorForStatus(t *testing.T) {97 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 50, 109}), colorForStatus(http.StatusOK), "2xx should be green")98 assert.Equal(t, string([]byte{27, 91, 57, 48, 59, 52, 55, 109}), colorForStatus(http.StatusMovedPermanently), "3xx should be white")99 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 51, 109}), colorForStatus(http.StatusNotFound), "4xx should be yellow")99 assert.Equal(t, string([]byte{27, 91, 57, 48, 59, 52, 51, 109}), colorForStatus(http.StatusNotFound), "4xx should be yellow")100 assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 49, 109}), colorForStatus(2), "other things should be red")101}102103func TestErrorLogger(t *testing.T) {
47 unmodified lines
modified:logger.go+1 added-1 removed
15 unmodified lines
1617var (18 green = string([]byte{27, 91, 57, 55, 59, 52, 50, 109})19 white = string([]byte{27, 91, 57, 48, 59, 52, 55, 109})20 yellow = string([]byte{27, 91, 57, 55, 59, 52, 51, 109})20 yellow = string([]byte{27, 91, 57, 48, 59, 52, 51, 109})21 red = string([]byte{27, 91, 57, 55, 59, 52, 49, 109})22 blue = string([]byte{27, 91, 57, 55, 59, 52, 52, 109})23 magenta = string([]byte{27, 91, 57, 55, 59, 52, 53, 109})24 cyan = string([]byte{27, 91, 57, 55, 59, 52, 54, 109})
128 unmodified lines