func (c *Core) enableAudit(entry *MountEntry) error {
	if !strings.HasSuffix(entry.Path, "/") {
		entry.Path += "/"
	}
	if entry.Path == "/" {
		return fmt.Errorf("backend path must be specified")
	}
	c.auditLock.Lock()
	defer c.auditLock.Unlock()
	for _, ent := range c.audit.Entries {
		switch {
		case strings.HasPrefix(ent.Path, entry.Path):
			fallthrough
		case strings.HasPrefix(entry.Path, ent.Path):
			return fmt.Errorf("path already in use")
		}
	}
	entryUUID, err := uuid.GenerateUUID()
	if err != nil {
		return err
	}
	entry.UUID = entryUUID
	view := NewBarrierView(c.barrier, auditBarrierPrefix+entry.UUID+"/")
	backend, err := c.newAuditBackend(entry, view, entry.Options)
	if err != nil {
		return err
	}
	newTable := c.audit.shallowClone()
	newTable.Entries = append(newTable.Entries, entry)
	if err := c.persistAudit(newTable); err != nil {
		return errors.New("failed to update audit table")
	}
	c.audit = newTable
	c.auditBroker.Register(entry.Path, backend, view)
	if c.logger.IsInfo() {
		c.logger.Info("core: enabled audit backend", "path", entry.Path, "type", entry.Type)
	}
	return nil
}
enableAudit is used to enable a new audit backend
package vault
import (
	"crypto/sha256"
	"encoding/json"
	"errors"
	"fmt"
	"strings"
	"sync"
	"time"
	log "github.com/mgutz/logxi/v1"
	"github.com/armon/go-metrics"
	"github.com/hashicorp/go-multierror"
	"github.com/hashicorp/go-uuid"
	"github.com/hashicorp/vault/audit"
	"github.com/hashicorp/vault/helper/jsonutil"
	"github.com/hashicorp/vault/helper/salt"
	"github.com/hashicorp/vault/logical"
)
const (
	coreAuditConfigPath = "core/audit"
	auditBarrierPrefix = "audit/"
	auditTableType = "audit"
)
var (
	errLoadAuditFailed = errors.New("failed to setup audit table")
)