dd0e8eec14
* copyright headers for agent folder * Ignore test data files * fix proto files and remove headers in agent/uiserver folder * ignore deep-copy files
35 lines
563 B
Go
35 lines
563 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package consul
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
)
|
|
|
|
type loggerStore struct {
|
|
root hclog.Logger
|
|
l sync.Mutex
|
|
cache map[string]hclog.Logger
|
|
}
|
|
|
|
func newLoggerStore(root hclog.Logger) *loggerStore {
|
|
return &loggerStore{
|
|
root: root,
|
|
cache: make(map[string]hclog.Logger),
|
|
}
|
|
}
|
|
|
|
func (ls *loggerStore) Named(name string) hclog.Logger {
|
|
ls.l.Lock()
|
|
defer ls.l.Unlock()
|
|
l, ok := ls.cache[name]
|
|
if !ok {
|
|
l = ls.root.Named(name)
|
|
ls.cache[name] = l
|
|
}
|
|
return l
|
|
}
|