func (f *Formatter) Format(entry *Entry, raw json.RawMessage, prefix, suffix []byte) error {
	color.NoColor = !f.Colorize
	f.enhance(entry)
	err := f.outputSimple(prefix, f.ShowPrefix)
	if err != nil {
		return err
	}
	err = f.template.Execute(f.output, entry)
	if err != nil {
		return err
	}
	f.outputFields(entry, raw)
	err = f.outputSimple(suffix, f.ShowSuffix)
	if err != nil {
		return err
	}
	err = stacktrace(f.output, raw)
	if err != nil {
		return err
	}
	_, err = f.output.Write(NewLine)
	return err
}
Format takes a structured log entry and formats it according the template.
package structure
import (
	"encoding/json"
	"fmt"
	"io"
	"sort"
	"strconv"
	"strings"
	"text/template"
	"time"
	"github.com/fatih/color"
)
const DefaultTemplate = `{{if .Timestamp}}[{{.Timestamp.Format "2006-01-02 15:04:05"}}] {{else if .RawTimestamp}}[{{.RawTimestamp}}] {{end}}{{if .Severity}}{{.Severity}}: {{end}}{{.Message}}`
var severityMapping = map[string]string{
	"10":   "TRACE",
	"20":   "DEBUG",
	"30":   "INFO",
	"40":   "WARNING",
	"WARN": "WARNING",
	"50":   "ERROR",
	"60":   "FATAL",
}
var fieldsToSkip = []string{
	"@timestamp", "hostname", "level", "message", "msg", "name", "pid", "severity", "text", "time", "timestamp", "ts", "v",
}
var NewLine = []byte("\n")
type Formatter struct {
	output   io.Writer
	template *template.Template
	Colorize      bool
	ShowFields    bool
	ShowPrefix    bool
	ShowSuffix    bool
	IncludeFields string
}
func NewFormatter(w io.Writer, fmt string) (*Formatter, error) {
	if fmt == "" {
		fmt = DefaultTemplate
	}
	tmpl, err := template.New("out").Parse(fmt)
	if err != nil {
		return nil, err
	}
	return &Formatter{
		output:        w,
		template:      tmpl,
		Colorize:      false,
		ShowFields:    true,
		ShowPrefix:    true,
		ShowSuffix:    true,
		IncludeFields: "",
	}, nil
}