mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
Make TestLogger an InterceptLogger and use it a little more widely. (#22030)
This commit is contained in:
@@ -414,7 +414,7 @@ func (n *NoopAudit) RegisterNodesAndPipeline(broker *eventlogger.Broker, _ strin
|
||||
}
|
||||
|
||||
type TestLogger struct {
|
||||
hclog.Logger
|
||||
hclog.InterceptLogger
|
||||
Path string
|
||||
File *os.File
|
||||
sink hclog.SinkAdapter
|
||||
@@ -446,6 +446,7 @@ func NewTestLogger(t testing.T) *TestLogger {
|
||||
logger := hclog.NewInterceptLogger(&hclog.LoggerOptions{
|
||||
Output: io.Discard,
|
||||
IndependentLevels: true,
|
||||
Name: t.Name(),
|
||||
})
|
||||
sink := hclog.NewSinkAdapter(&hclog.LoggerOptions{
|
||||
Output: output,
|
||||
@@ -454,13 +455,13 @@ func NewTestLogger(t testing.T) *TestLogger {
|
||||
})
|
||||
logger.RegisterSink(sink)
|
||||
return &TestLogger{
|
||||
Path: logPath,
|
||||
File: logFile,
|
||||
Logger: logger,
|
||||
sink: sink,
|
||||
Path: logPath,
|
||||
File: logFile,
|
||||
InterceptLogger: logger,
|
||||
sink: sink,
|
||||
}
|
||||
}
|
||||
|
||||
func (tl *TestLogger) StopLogging() {
|
||||
tl.Logger.(hclog.InterceptLogger).DeregisterSink(tl.sink)
|
||||
tl.InterceptLogger.DeregisterSink(tl.sink)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user