// RedisLogColorizer filters the Redis log output and colorizes it.
14194
func RedisLogColorizer(wr io.Writer) io.Writer {
	if !istty(wr) {
		return wr
	}
	pr, pw := io.Pipe()
	go func() {
		rd := bufio.NewReader(pr)
		for {
			line, err := rd.ReadString('\n')
			if err != nil {
				return
			}
			parts := strings.Split(line, " ")
			if len(parts) > 5 {
				var color string
				switch parts[4] {
				case ".":
					color = "\x1b[35m"
				case "-":
					color = ""
				case "*":
					color = "\x1b[1m"
				case "#":
					color = "\x1b[33m"
				}
				if color != "" {
					parts[4] = color + parts[4] + "\x1b[0m"
					line = strings.Join(parts, " ")
				}
			}
			os.Stdout.Write([]byte(line))
			continue
		}
	}()
	return pw
}
460063
func (writer *MultiWriter) SetColored(colored bool) {
	writer.colored = colored
	for _, fileWriter := range writer.writers {
		fileWriter.SetColored(colored)
	}
}
263517
func (c *ColorLogger) Err(bytes []byte) {
	if len(bytes) == 0 {
		return
	}
	logFmt, name := c.getLogFmt()
	message := fmt.Sprintf(logFmt, name, string(bytes))
	fmt.Fprint(os.Stderr, message)
}
1075226
func (i *Index) WithLogger(l *zap.Logger) {
	i.logger = l.With(zap.String("index", "tsi"))
}
831294
func (e *ErrorLogLogger) ErrorLogger(err error) Logger {
	return e.ErrHandler.ErrorLogger(err)
}
1212007
func (writer *baseFileWriter) Colored() bool {
	writer.lock.RLock()
	defer writer.lock.RUnlock()
	return writer.colored
}
732572
func (r *readlineUI) PrintErr(args ...interface{}) {
	text := fmt.Sprint(args...)
	if !strings.HasSuffix(text, "\n") {
		text += "\n"
	}
	if readline.IsTerminal(int(syscall.Stderr)) {
		text = colorize(text)
	}
	fmt.Fprint(r.rl.Stderr(), text)
}
607318
func NewSimpleLogger(w io.Writer, lvl Level, prefix string, color bool) *Logger {
	l := &Logger{}
	r := NewReceiver(w, prefix)
	r.Color = color
	r.Level = lvl
	l.Receivers = []*Receiver{r}
	l.Active = true
	return l
}
575728
func Colorize(c Color, b BackgroundColor, text string) string {
	return fmt.Sprintf("%s%s%s%s%s", ResetColors, c, b, text, ResetColors.String())
}
424023
func (c *ColorLoggerFactory) create(name string) logger.Logger {
	if c.maxLength < len(name) {
		c.maxLength = len(name)
	}

	return &ColorLogger{
		name:        name,
		factory:     c,
		colorPrefix: <-colorPrefix,
	}
}
1203769
func LogClear(msg string, v ...interface{}) {
	term.MoveUp(1)
	term.ClearLine()
	fmt.Printf("\r     %s\n", colors.Purple(fmt.Sprintf(msg, v...)))
}
1075342
func NewModeColorWriter(w io.Writer, mode outputMode) io.Writer {
	if _, ok := w.(*colorWriter); !ok {
		return &colorWriter{
			w:    w,
			mode: mode,
		}
	}
	return w
}
1117462
func (s *Service) initLogger() {
	log.SetLevel(s.options.LogSeverity.S)
	// If LogFormatter is specified then Log is ignored.
	if s.options.LogFormatter != nil {
		log.SetOutput(os.Stdout)
		log.SetFormatter(s.options.LogFormatter)
		return
	}
	if s.options.Log == "console" {
		log.SetOutput(os.Stdout)
		log.SetFormatter(&log.TextFormatter{})
		return
	}
	var err error
	if s.options.Log == "syslog" {
		var devNull *os.File
		devNull, err = os.OpenFile("/dev/null", os.O_WRONLY, 0)
		if err == nil {
			var hook *logrus_syslog.SyslogHook
			hook, err = logrus_syslog.NewSyslogHook("udp", "127.0.0.1:514", syslog.LOG_INFO|syslog.LOG_MAIL, "vulcand")
			if err == nil {
				log.SetOutput(devNull)
				log.SetFormatter(&log.TextFormatter{DisableColors: true})
				log.AddHook(hook)
				return
			}
		}
	}
	if s.options.Log == "json" {
		log.SetOutput(os.Stdout)
		log.SetFormatter(&log.JSONFormatter{})
		return
	}
	if s.options.Log == "logstash" {
		log.SetOutput(os.Stdout)
		log.SetFormatter(&logrus_logstash.LogstashFormatter{Fields: log.Fields{"type": "logs"}})
		return
	}
	log.SetOutput(os.Stdout)
	log.SetFormatter(&log.TextFormatter{})
	log.Warnf("Failed to initialized logger. Fallback to default: logger=%s, err=(%s)", s.options.Log, err)
}
1342193
func (p *Partition) WithLogger(logger *zap.Logger) {
	p.logger = logger.With(zap.String("index", "tsi"))
}
592617
func BrightRed(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.BrightRed()
	}
	return value{value: arg, color: BrightFg | RedFg}
}
724858
func WriterLogger(name string, level Level, format string, timeFormat string, out io.Writer, sync bool) (*Logger, error) {
	return createLogger(name, level, format, timeFormat, out, sync)
}
500184
func NoColor(msg string) string {
	empties := make(map[string]string, len(Colors))
	for k := range Colors {
		empties[k] = ""
	}
	return colorize(msg, empties)
}