// Format implements Formatter.Format.
179713
func (m MsgPack) Format(b []byte, l *Logger, t time.Time, severity int, msg string,
	fields map[string]interface{}) ([]byte, error) {
	b = append(b, byte(mpFixArray+3))
	b, err := appendMsgpack(b, l.Topic())
	if err != nil {
		return nil, err
	}
	b, err = appendMsgpack(b, t.Unix())
	if err != nil {
		return nil, err
	}

	// the log record consists of these objects:
	//     logged_at, severity, utsname, message, objects in fields,
	//     and objects in l.defaults excluding conflicting keys.
	var nFields uint64
	nFields += 4
	for k := range fields {
		if !ReservedKey(k) {
			nFields++
		}
	}
	for k := range l.Defaults() {
		if ReservedKey(k) {
			continue
		}
		if _, ok := fields[k]; ok {
			continue
		}
		nFields++
	}
	if nFields > math.MaxUint16 {
		return nil, ErrTooLarge
	}

	if nFields <= 15 {
		b = append(b, byte(mpFixMap+nFields))
	} else {
		b = append(b, byte(mpMap16), 0, 0)
		binary.BigEndian.PutUint16(b[len(b)-2:], uint16(nFields))
	}

	// logged_at
	b, err = appendMsgpack(b, FnLoggedAt)
	if err != nil {
		return nil, err
	}
	b, err = appendMsgpack(b, t.UnixNano()/1000)
	if err != nil {
		return nil, err
	}

	// severity
	b, err = appendMsgpack(b, FnSeverity)
	if err != nil {
		return nil, err
	}
	b, err = appendMsgpack(b, severity)
	if err != nil {
		return nil, err
	}

	// utsname
	b, err = appendMsgpack(b, FnUtsname)
	if err != nil {
		return nil, err
	}
	if len(m.Utsname) > 0 {
		b, err = appendMsgpack(b, m.Utsname)
	} else {
		b, err = appendMsgpack(b, utsname)
	}
	if err != nil {
		return nil, err
	}

	b, err = appendMsgpack(b, FnMessage)
	if err != nil {
		return nil, err
	}
	// message
	if len(b)+len(msg) > maxLogSize {
		return nil, ErrTooLarge
	}
	b, err = appendMsgpack(b, msg)
	if err != nil {
		return nil, err
	}

	// fields
	for k, v := range fields {
		if ReservedKey(k) {
			continue
		}
		if len(b)+len(k) > maxLogSize {
			return nil, ErrTooLarge
		}
		b, err = appendMsgpack(b, k)
		if err != nil {
			return nil, err
		}

		b, err = appendMsgpack(b, v)
		if err != nil {
			return nil, err
		}
	}

	// defaults
	for k, v := range l.Defaults() {
		if ReservedKey(k) {
			continue
		}
		if _, ok := fields[k]; ok {
			continue
		}
		if len(b)+len(k) > maxLogSize {
			return nil, ErrTooLarge
		}
		b, err = appendMsgpack(b, k)
		if err != nil {
			return nil, err
		}

		b, err = appendMsgpack(b, v)
		if err != nil {
			return nil, err
		}
	}

	return b, nil
}
1117649
func Format(record []string) string {
	buffer := bytes.NewBufferString("")
	writer := csv.NewWriter(buffer)
	writer.Write(record)
	writer.Flush()
	return strings.TrimRight(buffer.String(), "\n")
}
890118
func (container *Container) Format(f fmt.State, c rune) {
	fmt.Fprintf(f, "%s (%s)",
		progress.FormatBytes(container.Size),
		container.Stats(),
	)
}
303261
func Formats() []Format {
	list := make([]Format, 0, len(formatsByName))
	for _, f := range formatsByName {
		list = append(list, *f)
	}
	return list
}
851001
func (d *Decoder) Format() *audio.Format {
	if d == nil {
		return nil
	}
	return &audio.Format{
		NumChannels: int(d.NumChans),
		SampleRate:  int(d.SampleRate),
		BitDepth:    int(d.BitDepth),
		Endianness:  binary.BigEndian,
	}
}
888244
func (p *PercentilesBucketAggregation) Format(format string) *PercentilesBucketAggregation {
	p.format = format
	return p
}
247329
func (sc *StringConstraint) Format(f string) *StringConstraint {
	sc.format = f
	return sc
}
188394
func (a *MaxBucketAggregation) Format(format string) *MaxBucketAggregation {
	a.format = format
	return a
}
1239450
func (t TimeFormatter) Format(w io.Writer, entry zapcore.Entry, fields []zapcore.Field) {
	fmt.Fprint(w, entry.Time.Format(t.Layout))
}
1006598
func (node *Set) Format(buf *TrackedBuffer) {
	if node.Scope == "" {
		buf.Myprintf("set %v%v", node.Comments, node.Exprs)
	} else {
		buf.Myprintf("set %v%s %v", node.Comments, node.Scope, node.Exprs)
	}
}
1021899
func (c Calendar) Format(datetime time.Time, pattern string) (string, error) {
	parsed, err := c.parseDateTimeFormat(pattern)
	if err != nil {
		return "", err
	}

	return c.formatDateTime(datetime, parsed)
}
284200
func (f *LiteralFormatter) Format(entry *log.Entry) ([]byte, error) {
	return []byte(entry.Message), nil
}
874183
func (a *BucketSelectorAggregation) Format(format string) *BucketSelectorAggregation {
	a.format = format
	return a
}
936021
func (a Address) Format(s fmt.State, c rune) {
	fmt.Fprintf(s, "%"+string(c), a[:])
}
1154124
func (e Error) Format(a ...interface{}) Error {
	e.Message = fmt.Sprintf(e.Message, a...)
	return e
}
295163
func (a *Angle) Format(f fmt.State, c rune) {
	s := state{
		State:  f,
		verb:   c,
		hrDeg:  a.Deg(),
		caller: fsAngle,
		sym:    a.Sym,
	}
	a.Err = s.writeFormatted()
}
90207
func Format(value interface{}) string {
	if value == nil {
		return "nil"
	}

	t := reflect.TypeOf(value)
	formatter := formatters[t.Kind().String()]
	if formatter == nil {
		formatter = formatters[t.String()]
	}

	if formatter == nil {
		if _, ok := t.MethodByName("Error"); ok == true {
			return formatString(value.(error).Error())
		} else {
			return formatString(fmt.Sprintf("%+v", value))
		}
	}

	return formatter(value)
}