Don't resetnamed

This commit is contained in:
Jeff Mitchell 2018-08-23 15:04:18 -04:00
parent ba0d029247
commit 362a92945e
8 changed files with 17 additions and 13 deletions

View File

@ -423,7 +423,7 @@ func (c *ServerCommand) Run(args []string) int {
c.UI.Error(fmt.Sprintf("Unknown storage type %s", config.Storage.Type))
return 1
}
backend, err := factory(config.Storage.Config, c.logger.ResetNamed("storage."+config.Storage.Type))
backend, err := factory(config.Storage.Config, c.logger.Named("storage."+config.Storage.Type))
if err != nil {
c.UI.Error(fmt.Sprintf("Error initializing storage of type %s: %s", config.Storage.Type, err))
return 1

View File

@ -308,7 +308,7 @@ func (c *Core) persistAudit(ctx context.Context, table *MountTable, localOnly bo
// setupAudit is invoked after we've loaded the audit able to
// initialize the audit backends
func (c *Core) setupAudits(ctx context.Context) error {
broker := NewAuditBroker(c.logger.ResetNamed("audit"))
broker := NewAuditBroker(c.baseLogger.Named("audit"))
c.auditLock.Lock()
defer c.auditLock.Unlock()
@ -379,7 +379,7 @@ func (c *Core) removeAuditReloadFunc(entry *MountEntry) {
c.reloadFuncsLock.Lock()
if c.logger.IsDebug() {
c.logger.ResetNamed("audit").Debug("removing reload function", "path", entry.Path)
c.baseLogger.Named("audit").Debug("removing reload function", "path", entry.Path)
}
delete(c.reloadFuncs, key)
@ -412,7 +412,7 @@ func (c *Core) newAuditBackend(ctx context.Context, entry *MountEntry, view logi
return nil, fmt.Errorf("nil backend returned from %q factory function", entry.Type)
}
auditLogger := c.logger.ResetNamed("audit")
auditLogger := c.baseLogger.Named("audit")
switch entry.Type {
case "file":

View File

@ -580,7 +580,7 @@ func (c *Core) newCredentialBackend(ctx context.Context, entry *MountEntry, sysV
config := &logical.BackendConfig{
StorageView: view,
Logger: c.logger.ResetNamed(fmt.Sprintf("auth.%s.%s", t, entry.Accessor)),
Logger: c.baseLogger.Named(fmt.Sprintf("auth.%s.%s", t, entry.Accessor)),
Config: conf,
System: sysView,
BackendUUID: entry.BackendAwareUUID,

View File

@ -274,7 +274,10 @@ type Core struct {
defaultLeaseTTL time.Duration
maxLeaseTTL time.Duration
logger log.Logger
// baseLogger is used to avoid ResetNamed as it strips useful prefixes in
// e.g. testing
baseLogger log.Logger
logger log.Logger
// cachingDisabled indicates whether caches are disabled
cachingDisabled bool
@ -482,6 +485,7 @@ func NewCore(conf *CoreConfig) (*Core, error) {
router: NewRouter(),
sealed: new(uint32),
standby: true,
baseLogger: conf.Logger,
logger: conf.Logger.Named("core"),
defaultLeaseTTL: conf.DefaultLeaseTTL,
maxLeaseTTL: conf.MaxLeaseTTL,
@ -534,15 +538,15 @@ func NewCore(conf *CoreConfig) (*Core, error) {
}
c.seal.SetCore(c)
c.sealUnwrapper = NewSealUnwrapper(phys, conf.Logger.ResetNamed("storage.sealunwrapper"))
c.sealUnwrapper = NewSealUnwrapper(phys, c.baseLogger.Named("storage.sealunwrapper"))
var ok bool
// Wrap the physical backend in a cache layer if enabled
if txnOK {
c.physical = physical.NewTransactionalCache(c.sealUnwrapper, conf.CacheSize, conf.Logger.ResetNamed("storage.cache"))
c.physical = physical.NewTransactionalCache(c.sealUnwrapper, conf.CacheSize, c.baseLogger.Named("storage.cache"))
} else {
c.physical = physical.NewCache(c.sealUnwrapper, conf.CacheSize, conf.Logger.ResetNamed("storage.cache"))
c.physical = physical.NewCache(c.sealUnwrapper, conf.CacheSize, c.baseLogger.Named("storage.cache"))
}
c.physicalCache = c.physical.(physical.ToggleablePurgemonster)

View File

@ -132,7 +132,7 @@ func (c *Core) setupExpiration() error {
view := c.systemBarrierView.SubView(expirationSubPath)
// Create the manager
mgr := NewExpirationManager(c, view, c.logger.ResetNamed("expiration"))
mgr := NewExpirationManager(c, view, c.baseLogger.Named("expiration"))
c.expiration = mgr
// Link the token store to this

View File

@ -925,7 +925,7 @@ func (c *Core) newLogicalBackend(ctx context.Context, entry *MountEntry, sysView
config := &logical.BackendConfig{
StorageView: view,
Logger: c.logger.ResetNamed(fmt.Sprintf("secrets.%s.%s", t, entry.Accessor)),
Logger: c.baseLogger.Named(fmt.Sprintf("secrets.%s.%s", t, entry.Accessor)),
Config: conf,
System: sysView,
BackendUUID: entry.BackendAwareUUID,

View File

@ -204,7 +204,7 @@ func NewPolicyStore(ctx context.Context, core *Core, baseView *BarrierView, syst
func (c *Core) setupPolicyStore(ctx context.Context) error {
// Create the policy store
sysView := &dynamicSystemView{core: c}
c.policyStore = NewPolicyStore(ctx, c, c.systemBarrierView, sysView, c.logger.ResetNamed("policy"))
c.policyStore = NewPolicyStore(ctx, c, c.systemBarrierView, sysView, c.baseLogger.Named("policy"))
if c.ReplicationState().HasState(consts.ReplicationPerformanceSecondary) {
// Policies will sync from the primary

View File

@ -242,7 +242,7 @@ func (c *Core) startRollback() error {
}
return ret
}
c.rollback = NewRollbackManager(c.activeContext, c.logger.ResetNamed("rollback"), backendsFunc, c.router, c)
c.rollback = NewRollbackManager(c.activeContext, c.baseLogger.Named("rollback"), backendsFunc, c.router, c)
c.rollback.Start()
return nil
}