func (s *StdoutClient) SendEvents(events map[string]event.Event) error {
	var n int
	var stats = make([]string, 0)
	for _, e := range events {
		for _, stat := range e.Stats() {
			stat = fmt.Sprintf("%s%s", s.prefix, strings.Replace(stat, "%HOST%", Hostname, 1))
			_n := n + len(stat) + 1
			if _n > UDPPayloadSize {
				if _, err := fmt.Fprintf(s.FD, strings.Join(stats, "\n")); err != nil {
					return err
				}
				stats = []string{stat}
				n = len(stat)
				continue
			}
			n = _n
			stats = append(stats, stat)
		}
	}
	if len(stats) != 0 {
		if _, err := fmt.Fprintf(s.FD, strings.Join(stats, "\n")); err != nil {
			return err
		}
	}
	return nil
}
SendEvents - Sends stats from all the event objects.
Tries to bundle many together into one fmt.Fprintf based on UDPPayloadSize.
package statsd
import (
	"fmt"
	"log"
	"os"
	"strings"
	"time"
	"github.com/quipo/statsd/event"
)
type StdoutClient struct {
	FD     *os.File
	prefix string
	Logger Logger
}
func NewStdoutClient(filename string, prefix string) *StdoutClient {
	var err error
	prefix = strings.Replace(prefix, "%HOST%", Hostname, 1)
	var fh *os.File
	if filename == "" {
		fh = os.Stdout
	} else {
		fh, err = os.OpenFile(filename, os.O_WRONLY, 0644)
		if nil != err {
			fmt.Printf("Cannot open file '%s' for stats output: %s\n", filename, err.Error())
		}
	}
	return &StdoutClient{
		FD:     fh,
		prefix: prefix,
		Logger: log.New(os.Stdout, "[StdoutClient] ", log.Ldate|log.Ltime),
	}
}
func (s *StdoutClient) CreateSocket() error {
	if s.FD == nil {
		s.FD = os.Stdout
	}
	return nil
}
func (s *StdoutClient) CreateTCPSocket() error {
	if s.FD == nil {
		s.FD = os.Stdout
	}
	return nil
}
func (s *StdoutClient) Close() error {
	return nil
}
func (s *StdoutClient) Incr(stat string, count int64) error {
	if 0 != count {
		return s.send(stat, "%d|c", count)
	}
	return nil
}
func (s *StdoutClient) Decr(stat string, count int64) error {
	if 0 != count {
		return s.send(stat, "%d|c", -count)
	}
	return nil
}
func (s *StdoutClient) Timing(stat string, delta int64) error {
	return s.send(stat, "%d|ms", delta)
}
func (s *StdoutClient) PrecisionTiming(stat string, delta time.Duration) error {
	return s.send(stat, "%.6f|ms", float64(delta)/float64(time.Millisecond))
}
func (s *StdoutClient) Gauge(stat string, value int64) error {
	if value < 0 {
		err := s.send(stat, "%d|g", 0)
		if nil != err {
			return err
		}
		return s.send(stat, "%d|g", value)
	}
	return s.send(stat, "%d|g", value)
}
func (s *StdoutClient) GaugeDelta(stat string, value int64) error {
	if value < 0 {
		return s.send(stat, "%d|g", value)
	}
	return s.send(stat, "+%d|g", value)
}
func (s *StdoutClient) FGauge(stat string, value float64) error {
	if value < 0 {
		err := s.send(stat, "%d|g", 0)
		if nil != err {
			return err
		}
		return s.send(stat, "%g|g", value)
	}
	return s.send(stat, "%g|g", value)
}
func (s *StdoutClient) FGaugeDelta(stat string, value float64) error {
	if value < 0 {
		return s.send(stat, "%g|g", value)
	}
	return s.send(stat, "+%g|g", value)
}
func (s *StdoutClient) Absolute(stat string, value int64) error {
	return s.send(stat, "%d|a", value)
}
func (s *StdoutClient) FAbsolute(stat string, value float64) error {
	return s.send(stat, "%g|a", value)
}
func (s *StdoutClient) Total(stat string, value int64) error {
	return s.send(stat, "%d|t", value)
}
func (s *StdoutClient) send(stat string, format string, value interface{}) error {
	stat = strings.Replace(stat, "%HOST%", Hostname, 1)
	format = fmt.Sprintf("%s%s:%s\n", s.prefix, stat, format)
	_, err := fmt.Fprintf(s.FD, format, value)
	return err
}
func (s *StdoutClient) SendEvent(e event.Event) error {
	for _, stat := range e.Stats() {
		_, err := fmt.Fprintf(s.FD, "%s%s", s.prefix, strings.Replace(stat, "%HOST%", Hostname, 1))
		if nil != err {
			return err
		}
	}
	return nil
}