func (b *Base) Level() LevelInfo {
	b.mutex.RLock()
	defer b.mutex.RUnlock()
	return b.level
}
Level reports the currently configured level for the Sender.
package send
import (
	"fmt"
	"sync"
	"github.com/mongodb/grip/message"
	"github.com/pkg/errors"
)
type Base struct {
	name   string
	level  LevelInfo
	mutex  sync.RWMutex
	closed bool
	errHandler ErrorHandler
	reset      func()
	closer     func() error
	formatter  MessageFormatter
}
func NewBase(n string) *Base {
	return &Base{
		name:       n,
		reset:      func() {},
		closer:     func() error { return nil },
		errHandler: func(error, message.Composer) {},
	}
}
func MakeBase(n string, reseter func(), closer func() error) *Base {
	b := NewBase(n)
	b.reset = reseter
	b.closer = closer
	return b
}
func (b *Base) Close() error {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	if b.closed {
		return nil
	}
	if b.closer != nil {
		if err := b.closer(); err != nil {
			return errors.WithStack(err)
		}
	}
	b.closed = true
	return nil
}
func (b *Base) Name() string {
	b.mutex.RLock()
	defer b.mutex.RUnlock()
	return b.name
}
func (b *Base) SetName(name string) {
	b.mutex.Lock()
	b.name = name
	b.mutex.Unlock()
	b.reset()
}
func (b *Base) SetFormatter(mf MessageFormatter) error {
	if mf == nil {
		return errors.New("cannot set message formatter to nil")
	}
	b.mutex.Lock()
	defer b.mutex.Unlock()
	b.formatter = mf
	return nil
}
func (b *Base) Formatter() MessageFormatter {
	return func(m message.Composer) (string, error) {
		b.mutex.RLock()
		defer b.mutex.RUnlock()
		if b.formatter == nil {
			return m.String(), nil
		}
		return b.formatter(m)
	}
}
func (b *Base) SetErrorHandler(eh ErrorHandler) error {
	if eh == nil {
		return errors.New("error handler must be non-nil")
	}
	b.mutex.Lock()
	defer b.mutex.Unlock()
	b.errHandler = eh
	return nil
}
func (b *Base) ErrorHandler() ErrorHandler {
	return func(err error, m message.Composer) {
		if err == nil {
			return
		}
		b.mutex.RLock()
		defer b.mutex.RUnlock()
		b.errHandler(err, m)
	}
}
func (b *Base) SetLevel(l LevelInfo) error {
	if !l.Valid() {
		return fmt.Errorf("level settings are not valid: %+v", l)
	}
	b.mutex.Lock()
	defer b.mutex.Unlock()
	b.level = l
	return nil
}