Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes file size check for pipe, not provided by linux. #1893

Merged
merged 2 commits into from
Apr 3, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Disable color on windows.
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena committed Apr 3, 2020
commit ee4191ad42c10d2519703bf0b97c37dd90ff804e
20 changes: 17 additions & 3 deletions pkg/promtail/client/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"fmt"
"os"
"runtime"
"sync"
"text/tabwriter"
"time"
Expand All @@ -13,6 +14,18 @@ import (
"gopkg.in/yaml.v2"
)

var (
yellow = color.New(color.FgYellow)
blue = color.New(color.FgBlue)
)

func init() {
if runtime.GOOS == "windows" {
yellow.DisableColor()
blue.DisableColor()
}
}

type logger struct {
*tabwriter.Writer
sync.Mutex
Expand All @@ -26,7 +39,8 @@ func NewLogger(cfgs ...Config) (Client, error) {
return nil, err
}
c.Stop()
fmt.Println(color.YellowString("Clients configured:"))

fmt.Println(yellow.Sprint("Clients configured:"))
for _, cfg := range cfgs {
yaml, err := yaml.Marshal(cfg)
if err != nil {
Expand All @@ -45,9 +59,9 @@ func (*logger) Stop() {}
func (l *logger) Handle(labels model.LabelSet, time time.Time, entry string) error {
l.Lock()
defer l.Unlock()
fmt.Fprint(l.Writer, color.BlueString(time.Format("2006-01-02T15:04:05")))
fmt.Fprint(l.Writer, blue.Sprint(time.Format("2006-01-02T15:04:05")))
fmt.Fprint(l.Writer, "\t")
fmt.Fprint(l.Writer, color.YellowString(labels.String()))
fmt.Fprint(l.Writer, yellow.Sprint(labels.String()))
fmt.Fprint(l.Writer, "\t")
fmt.Fprint(l.Writer, entry)
fmt.Fprint(l.Writer, "\n")
Expand Down