Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io"
"os"
"strings"

"github.com/motemen/go-colorine"
)
Expand Down Expand Up @@ -51,16 +50,13 @@ var (
)

func init() {
SelectLogger()
selectLogger()
}

func SelectLogger() {
v := os.Getenv("NO_COLOR")

if strings.ToLower(v) == "true" {
func selectLogger() {
if os.Getenv("NO_COLOR") != "" {
logger = loggerWithoutColor
}

SetOutput(os.Stderr)
}

Expand Down
4 changes: 2 additions & 2 deletions logger/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func TestLog(t *testing.T) {
t.Run("with color", func(t *testing.T) {
t.Logf("NO_COLOR: %s", os.Getenv("NO_COLOR"))
SelectLogger()
selectLogger()
// info
Log("default", "should be green")
// verbose
Expand All @@ -25,7 +25,7 @@ func TestLog(t *testing.T) {
t.Run("without color", func(t *testing.T) {
t.Setenv("NO_COLOR", "true")
t.Logf("NO_COLOR: %s", os.Getenv("NO_COLOR"))
SelectLogger()
selectLogger()
// info
Log("default", "should be none")
// verbose
Expand Down