From bbabd1b84150c98c40a49ec044893b8eb4010348 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 26 May 2023 21:15:29 +0800 Subject: [PATCH] fix --- modules/log/event_writer_base.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/log/event_writer_base.go b/modules/log/event_writer_base.go index 1d45d579c03a3..75369d60fd19b 100644 --- a/modules/log/event_writer_base.go +++ b/modules/log/event_writer_base.go @@ -68,18 +68,16 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) { } } - for { - if b.GetPauseChan != nil { - pause := b.GetPauseChan() - if pause != nil { - select { - case <-pause: - case <-ctx.Done(): - return - } + handlePaused := func() { + if pause := b.GetPauseChan(); pause != nil { + select { + case <-pause: + case <-ctx.Done(): } } + } + for { select { case <-ctx.Done(): return @@ -88,6 +86,8 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) { return } + handlePaused() + if exprRegexp != nil { fileLineCaller := fmt.Sprintf("%s:%d:%s", event.Origin.Filename, event.Origin.Line, event.Origin.Caller) matched := exprRegexp.Match([]byte(fileLineCaller)) || exprRegexp.Match([]byte(event.Origin.MsgSimpleText))