func (format *ToCSV) ApplyFormatter(msg *core.Message) error {
	csv := ""
	metadata := msg.GetMetadata()
	for _, key := range format.keys {
		if value, ok := metadata.Value(key); ok {
			switch v := value.(type) {
			case bool:
				csv = fmt.Sprintf("%s%t%s", csv, v, format.separator)
			case int8, int16, int32, int64:
				csv = fmt.Sprintf("%s%d%s", csv, v, format.separator)
			case uint8, uint16, uint32, uint64:
				csv = fmt.Sprintf("%s%d%s", csv, v, format.separator)
			case float32, float64:
				csv = fmt.Sprintf("%s%f%s", csv, v, format.separator)
			case string:
				csv = fmt.Sprintf("%s%s%s", csv, v, format.separator)
			default:
				format.Logger.WithField("key", key).Warning("unsupported datatype")
				csv += format.separator
			}
		} else {
			format.Logger.WithField("key", key).Warning("key not found")
			csv += format.separator
		}
	}
	if !format.keepLastSeparator && len(csv) >= len(format.separator) {
		csv = csv[:len(csv)-len(format.separator)]
	}
	format.SetTargetData(msg, csv)
	return nil
}
ApplyFormatter update message payload
package format
import (
	"fmt"
	"gollum/core"
)
type ToCSV struct {
	core.SimpleFormatter `gollumdoc:"embed_type"`
	separator            string   `config:"Separator" default:","`
	keys                 []string `config:"Keys"`
	keepLastSeparator    bool     `config:"KeepLastSeparator"`
}
func init() {
	core.TypeRegistry.Register(ToCSV{})
}
func (format *ToCSV) Configure(conf core.PluginConfigReader) {
}