Skip to content

Commit

Permalink
fix logging in monitoring job receiver (#1311)
Browse files Browse the repository at this point in the history
* fix logging in monitoring job receiver

Signed-off-by: Christian Kruse <[email protected]>

* Use zap fields instead of fmt.

Co-authored-by: Mikołaj Świątek <[email protected]>

---------

Signed-off-by: Christian Kruse <[email protected]>
Co-authored-by: Mikołaj Świątek <[email protected]>
  • Loading branch information
c-kruse and swiatekm authored Oct 31, 2023
1 parent 4c62e5f commit 83946b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/receiver/jobreceiver/output/logentries/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func (h *handler) Consume(ctx context.Context, stdout, stderr io.Reader) consume
go h.consume(ctx, stderr, streamNameStderr)
return nopCloser
}
func (h *handler) consume(ctx context.Context, in io.Reader, stream string) {

// TODO(ck) add buffer between reading and processing #1309
func (h *handler) consume(ctx context.Context, in io.Reader, stream string) {
scanner := h.scanFactory.Build(in)
for scanner.Scan() {
ent, err := h.writer.NewEntry(scanner.Text())
Expand All @@ -48,7 +49,7 @@ func (h *handler) consume(ctx context.Context, in io.Reader, stream string) {
h.writer.Write(ctx, ent)
}
if err := scanner.Err(); err != nil {
h.logger.Errorf("error reading input stream %s: %w", stream, err)
h.logger.Errorf("error reading input stream", zap.String("stream", stream), zap.Error(err))
}
}

Expand Down

0 comments on commit 83946b0

Please sign in to comment.