Skip to content

Commit aacea74

Browse files
committed
Avoid excessive warning messages on StdErr
Signed-off-by: JamesJJ <[email protected]>
1 parent 5b04f68 commit aacea74

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fluent/fluent.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ func (f *Fluent) connect() (err error) {
354354

355355
func (f *Fluent) run() {
356356
drainEvents := false
357+
var emitEventDrainMsg sync.Once
357358
for {
358359
select {
359360
case stopRunning, ok := <-f.stopRunning:
@@ -369,7 +370,7 @@ func (f *Fluent) run() {
369370
return
370371
}
371372
if drainEvents {
372-
fmt.Fprintf(os.Stderr, "[%s] Unable to send logs to fluentd, discarding...\n", time.Now().Format(time.RFC3339))
373+
emitEventDrainMsg.Do(func() { fmt.Fprintf(os.Stderr, "[%s] Discarding queued events...\n", time.Now().Format(time.RFC3339)) })
373374
continue
374375
}
375376
err := f.write(entry)

0 commit comments

Comments
 (0)