func MakeSplunkLogger(name string) (Sender, error) {
	info := GetSplunkConnectionInfo()
	if err := info.validateFromEnv(); err != nil {
		return nil, errors.WithStack(err)
	}
	return NewSplunkLogger(name, info, LevelInfo{level.Trace, level.Trace})
}
MakeSplunkLogger constructs a new Sender implementation that reads
the hostname, username, and password from environment variables:

GRIP_SPLUNK_SERVER_URL
GRIP_SPLUNK_CLIENT_TOKEN
GRIP_SPLUNK_CLIENT_CHANNEL
package send
import (
	"context"
	"crypto/tls"
	"net/http"
	"os"
	"time"
	hec "github.com/fuyufjh/splunk-hec-go"
	"github.com/mongodb/grip/level"
	"github.com/mongodb/grip/message"
	"github.com/pkg/errors"
)
const (
	splunkServerURL   = "GRIP_SPLUNK_SERVER_URL"
	splunkClientToken = "GRIP_SPLUNK_CLIENT_TOKEN"
	splunkChannel     = "GRIP_SPLUNK_CHANNEL"
)
type splunkLogger struct {
	info     SplunkConnectionInfo
	client   splunkClient
	hostname string
	*Base
}
type SplunkConnectionInfo struct {
	ServerURL string `bson:"url" json:"url" yaml:"url"`
	Token     string `bson:"token" json:"token" yaml:"token"`
	Channel   string `bson:"channel" json:"channel" yaml:"channel"`
}
func GetSplunkConnectionInfo() SplunkConnectionInfo {
	return SplunkConnectionInfo{
		ServerURL: os.Getenv(splunkServerURL),
		Token:     os.Getenv(splunkClientToken),
		Channel:   os.Getenv(splunkChannel),
	}
}
func (info SplunkConnectionInfo) Populated() bool {
	return info.ServerURL != "" && info.Token != ""
}
func (info SplunkConnectionInfo) validateFromEnv() error {
	if info.ServerURL == "" {
		return errors.Errorf("environment variable %s not defined, cannot create splunk client", splunkServerURL)
	}
	if info.Token == "" {
		return errors.Errorf("environment variable %s not defined, cannot create splunk client", splunkClientToken)
	}
	return nil
}
func (s *splunkLogger) Send(m message.Composer) {
	lvl := s.Level()
	if lvl.ShouldLog(m) {
		g, ok := m.(*message.GroupComposer)
		if ok {
			batch := []*hec.Event{}
			for _, c := range g.Messages() {
				if lvl.ShouldLog(c) {
					e := hec.NewEvent(c.Raw())
					e.SetHost(s.hostname)
					batch = append(batch, e)
				}
			}
			if err := s.client.WriteBatch(batch); err != nil {
				s.ErrorHandler()(err, m)
			}
			return
		}
		e := hec.NewEvent(m.Raw())
		e.SetHost(s.hostname)
		if err := s.client.WriteEvent(e); err != nil {
			s.ErrorHandler()(err, m)
		}
	}
}
func (s *splunkLogger) Flush(_ context.Context) error { return nil }
func NewSplunkLogger(name string, info SplunkConnectionInfo, l LevelInfo) (Sender, error) {
	client := (&http.Client{
		Transport: &http.Transport{
			Proxy:               http.ProxyFromEnvironment,
			DisableKeepAlives:   true,
			TLSHandshakeTimeout: 5 * time.Second,
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true,
			},
		},
		Timeout: 5 * time.Second,
	})
	s, err := buildSplunkLogger(name, client, info, l)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	if err := s.client.Create(client, info); err != nil {
		return nil, errors.WithStack(err)
	}
	return s, nil
}
func NewSplunkLoggerWithClient(name string, info SplunkConnectionInfo, l LevelInfo, client *http.Client) (Sender, error) {
	s, err := buildSplunkLogger(name, client, info, l)
	if err != nil {
		return nil, errors.WithStack(err)
	}
	if err := s.client.Create(client, info); err != nil {
		return nil, errors.WithStack(err)
	}
	return s, nil
}
func buildSplunkLogger(name string, client *http.Client, info SplunkConnectionInfo, l LevelInfo) (*splunkLogger, error) {
	s := &splunkLogger{
		info:   info,
		client: &splunkClientImpl{},
		Base:   NewBase(name),
	}
	hostname, err := os.Hostname()
	if err != nil {
		return nil, errors.WithStack(err)
	}
	s.hostname = hostname
	if err := s.SetLevel(l); err != nil {
		return nil, errors.WithStack(err)
	}
	return s, nil
}