// Initialize the formatter with specified format strings.
// Allow for specialized date formatting with the dateFormat arguement.
766432
func NewStandardFormatter(format string, dateFormat string) *StandardFormatter {
	toFormatTime := false
	size := 0
	f1 := func(match string) string {
		if match == "%%" {
			return "%"
		}
		if match == "%(asctime)s" {
			toFormatTime = true
		}
		size++
		return "%s"
	}
	strFormat := formatRe.ReplaceAllStringFunc(format, f1)
	funs := make([]ExtractAttr, 0, size)
	f2 := func(match string) string {
		extractFunc, ok := attrToFunc[match]
		if ok {
			funs = append(funs, extractFunc)
		}
		return match
	}
	formatRe.ReplaceAllStringFunc(format, f2)
	getFormatArgsFunc := func(record *LogRecord) []interface{} {
		result := make([]interface{}, 0, len(funs))
		for _, f := range funs {
			result = append(result, f(record))
		}
		return result
	}
	var dateFormatter *strftime.Formatter
	if toFormatTime {
		dateFormatter = strftime.NewFormatter(dateFormat)
	}
	return &StandardFormatter{
		format:            format,
		strFormat:         strFormat + "\n",
		getFormatArgsFunc: getFormatArgsFunc,
		toFormatTime:      toFormatTime,
		dateFormat:        dateFormat,
		dateFormatter:     dateFormatter,
	}
}
369378
func (s *Stopwatch) SetStringFormat(f func(time.Duration) string) {
	s.Lock()
	defer s.Unlock()

	s.format = f
}
1253606
func (b *Base) SetFormatter(mf MessageFormatter) error {
	if mf == nil {
		return errors.New("cannot set message formatter to nil")
	}

	b.mutex.Lock()
	defer b.mutex.Unlock()
	b.formatter = mf

	return nil
}
1237787
func (s *Playlist) SetFormat(v string) *Playlist {
	s.Format = &v
	return s
}
441124
func FormatMap(m map[string]string) string {
	keys := make([]string, 0, len(m))
	values := make([]string, 0, len(m))
	for k, v := range m {
		keys = append(keys, k)
		values = append(values, v)
	}
	return FormatOrderedMap(keys, values)
}
390903
func (s *BusinessReportSchedule) SetFormat(v string) *BusinessReportSchedule {
	s.Format = &v
	return s
}
1201289
func formatArgs(args ...interface{}) []string {
	formatted := make([]string, 0, len(args))
	for _, a := range args {
		s := colorize(pretty.Sprint(a), cyan)
		formatted = append(formatted, s)
	}
	return formatted
}
351549
func Init() {
	switch *streamlog.QueryLogFormat {
	case streamlog.QueryLogFormatText:
	case streamlog.QueryLogFormatJSON:
	default:
		log.Exitf("Invalid querylog-format value %v: must be either text or json", *streamlog.QueryLogFormat)
	}

	if *queryLogHandler != "" {
		StatsLogger.ServeLogs(*queryLogHandler, streamlog.GetFormatter(StatsLogger))
	}

	if *txLogHandler != "" {
		TxLogger.ServeLogs(*txLogHandler, streamlog.GetFormatter(TxLogger))
	}
}
292490
func FormatLabels(labelMap map[string]string) string {
	l := Set(labelMap).String()
	if l == "" {
		l = "<none>"
	}
	return l
}
566453
func (s *sequenceDecs) initialize(br *bitReader, hist *history, literals, out []byte) error {
	if err := s.litLengths.init(br); err != nil {
		return errors.New("litLengths:" + err.Error())
	}
	if err := s.offsets.init(br); err != nil {
		return errors.New("litLengths:" + err.Error())
	}
	if err := s.matchLengths.init(br); err != nil {
		return errors.New("matchLengths:" + err.Error())
	}
	s.literals = literals
	s.hist = hist.b
	s.prevOffset = hist.recentOffsets
	s.maxBits = s.litLengths.fse.maxBits + s.offsets.fse.maxBits + s.matchLengths.fse.maxBits
	s.out = out
	return nil
}
243987
func (c *commandBase) Initialize(params *Parameters) {
	c.p = params
	c.f.Register(c.GetFlags(), params)
}
1290318
func (s *GetTypeInput) SetFormat(v string) *GetTypeInput {
	s.Format = &v
	return s
}
1255309
func SetFormatter(f Formatter) {
	logger.Lock()
	defer logger.Unlock()
	logger.formatter = f
}
1213498
func setupFormatter() logrus.Formatter {
	fileFormat := new(logrus.TextFormatter)
	fileFormat.DisableTimestamp = true
	fileFormat.DisableColors = true
	switch os.Getenv("INITSYSTEM") {
	case "SYSTEMD":
		fileFormat.FullTimestamp = true
	default:
		fileFormat.TimestampFormat = time.RFC3339
	}

	// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
	return fileFormat
}
162365
func formatAsString(v reflect.Value, kind reflect.Kind) string {
	if kind == reflect.Ptr && !v.IsNil() {
		v = v.Elem()
	}

	return fmt.Sprintf("%v", v.Interface())
}
883480
func FormatStringList(list []string) (fields []interface{}) {
	fields = make([]interface{}, len(list))
	for i, v := range list {
		fields[i] = v
	}
	return
}
914127
func NewFormatted(base string, args ...interface{}) Composer {
	return &formatMessenger{
		base: base,
		args: args,
	}
}