Skip to content

Commit

Permalink
Added the --all option to journald and cleaned up wait groups (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwilliams89 authored Sep 8, 2021
1 parent 5fc3cd8 commit fe917a6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions operator/builtin/input/journald/journald.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (c JournaldInputConfig) Build(buildContext operator.BuildContext) ([]operat
// Export logs as JSON
args = append(args, "--output=json")

// Show all fields without encoding or truncation
args = append(args, "--all")

// Give raw json output and then exit the process
args = append(args, "--no-pager")

Expand Down Expand Up @@ -138,11 +141,12 @@ func (operator *JournaldInput) Start() error {
// checking if there are new files or new logs in the watched files
func (operator *JournaldInput) startPoller(ctx context.Context) {
operator.Debug("starting poller")
go func() {
globTicker := time.NewTicker(operator.pollInterval)
operator.wg.Add(1)
operator.wg.Add(1)

go func() {
defer operator.wg.Done()

globTicker := time.NewTicker(operator.pollInterval)
defer globTicker.Stop()

for {
Expand All @@ -163,9 +167,6 @@ func (operator *JournaldInput) startPoller(ctx context.Context) {

// poll checks all the watched paths for new entries
func (operator *JournaldInput) poll(ctx context.Context) error {
operator.wg.Add(1)

defer operator.wg.Done()
defer operator.syncOffsets()

// Start from a cursor if there is a saved offset
Expand Down

0 comments on commit fe917a6

Please sign in to comment.