func (p *DefaultFormatter) Format(rec *LogRec, level Level, buf *bytes.Buffer) (*bytes.Buffer, error) {
	if buf == nil {
		buf = &bytes.Buffer{}
	}
	timestampFmt := DefTimestampFormat
	buf.WriteString(rec.Time().Format(timestampFmt))
	buf.Write(Space)
	buf.WriteString(level.Name)
	buf.Write(Space)
	buf.WriteString(rec.Msg())
	buf.Write(Space)
	fields := rec.Fields()
	if len(fields) > 0 {
		if err := WriteFields(buf, fields, Space, NoColor); err != nil {
			return nil, err
		}
	}
	if level.Stacktrace {
		frames := rec.StackFrames()
		if len(frames) > 0 {
			buf.Write(Newline)
			if err := WriteStacktrace(buf, rec.StackFrames()); err != nil {
				return nil, err
			}
		}
	}
	buf.Write(Newline)
	return buf, nil
}
Format converts a log record to bytes.
package logr
import (
	"bytes"
	"io"
	"runtime"
	"strconv"
)
type Formatter interface {
	IsStacktraceNeeded() bool
	Format(rec *LogRec, level Level, buf *bytes.Buffer) (*bytes.Buffer, error)
}
const (
	DefTimestampFormat = "2006-01-02 15:04:05.000 Z07:00"
	TimestampMillisFormat = "Jan _2 15:04:05.000"
)
type Writer struct {
	io.Writer
}
func (w Writer) Writes(elems ...[]byte) (int, error) {
	var count int
	for _, e := range elems {
		if c, err := w.Write(e); err != nil {
			return count + c, err
		} else {
			count += c
		}
	}
	return count, nil
}
type DefaultFormatter struct {
}
func (p *DefaultFormatter) IsStacktraceNeeded() bool {
	return false
}