From dce39f3a93ca04112ccfabe594bd8c8ab6ce05cf Mon Sep 17 00:00:00 2001 From: Stephen Fox Jr Date: Wed, 22 Mar 2023 13:11:16 -0400 Subject: [PATCH] app: Added debug logs on Go routine worker exits. --- internal/app/app.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index 558f2e25..0045f950 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -105,7 +105,7 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig logDirReader, err := auditd.StartLogDirReader(groupCtx, auditLogDirPath) if err != nil { - return fmt.Errorf("failed to create audit dir reader for '%s' - %w", + return fmt.Errorf("failed to create linux audit dir reader for '%s' - %w", auditLogDirPath, err) } @@ -115,7 +115,13 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig h.OnReady() }() - eg.Go(logDirReader.Wait) + eg.Go(func() error { + err := logDirReader.Wait() + if logger.Level() == zap.DebugLevel { + logger.Debugf("linux audit log dir reader worker exited (%v)", err) + } + return err + }) lastReadJournalTS := lastReadJournalTimeStamp() eventWriter := auditevent.NewDefaultAuditEventWriter(auf) @@ -135,7 +141,12 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig CurrentTS: lastReadJournalTS, Health: h, } - return jp.Read(groupCtx) + + err := jp.Read(groupCtx) + if logger.Level() == zap.DebugLevel { + logger.Debugf("journald worker exited (%v)", err) + } + return err }) h.AddReadiness() @@ -147,7 +158,12 @@ func Run(ctx context.Context, osArgs []string, h *common.Health, optLoggerConfig EventW: eventWriter, Health: h, } - return ap.Read(groupCtx) + + err := ap.Read(groupCtx) + if logger.Level() == zap.DebugLevel { + logger.Debugf("audit worker exited (%v)", err) + } + return err }) if err := eg.Wait(); err != nil {