Skip to content

Commit

Permalink
Fix debug action: it reuses logger between pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimalekseev committed Oct 5, 2023
1 parent 6a6890e commit c27544d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions plugin/action/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ var (

// return shared logger between concurrent running processors
func (p *Plugin) setupLogger(pipelineName string, parentLogger *zap.Logger, config *Config) {
if config.Interval_ == 0 {
p.logger = parentLogger
}

loggerByPipelineMu.Lock()
defer loggerByPipelineMu.Unlock()

// TODO: the playground can break this logic
lg, ok := loggerByPipeline[pipelineName]
if !ok {
if config.Interval_ != 0 {
// enable sampler
lg = parentLogger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return zapcore.NewSamplerWithOptions(parentLogger.Core(), config.Interval_, config.First, config.Thereafter)
}))
} else {
lg = parentLogger
}
loggerByPipeline[pipelineName] = lg
// enable sampler
lg = parentLogger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return zapcore.NewSamplerWithOptions(parentLogger.Core(), config.Interval_, config.First, config.Thereafter)
}))
}
p.logger = lg
loggerByPipeline[pipelineName] = lg
}

0 comments on commit c27544d

Please sign in to comment.