cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.65.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmd/pint/logger.go

30lines · modecode

1package main
2
3import (
4 "fmt"
5 "os"
6
7 "github.com/fatih/color"
8
9 "github.com/cloudflare/pint/internal/log"
10)
11
12func initLogger(level string, noColor bool) error {
13 l, err := log.ParseLevel(level)
14 if err != nil {
15 return fmt.Errorf("'%s' is not a valid log level", level)
16 }
17
18 nc := os.Getenv("NO_COLOR")
19 if nc != "" && nc != "0" {
20 noColor = true
21 }
22 // Override fatih/color detection of when to **disable** coloring.
23 if !noColor {
24 color.NoColor = false
25 }
26
27 log.Setup(l, noColor)
28
29 return nil
30}
31