Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clients/destination/v0/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ func (c *Client) newManagedClient(ctx context.Context, path string) error {
break
}
if errors.Is(err, logging.ErrLogLineToLong) {
c.logger.Err(err).Str("line", string(line)).Msg("skipping too long log line")
c.logger.Info().Str("line", string(line)).Msg("truncated destination plugin log line")
continue
}
if err != nil {
c.logger.Err(err).Msg("failed to read log line from plugin")
c.logger.Err(err).Msg("failed to read log line from destination plugin")
break
}
var structuredLogLine map[string]any
if err := json.Unmarshal(line, &structuredLogLine); err != nil {
c.logger.Err(err).Str("line", string(line)).Msg("failed to unmarshal log line from plugin")
c.logger.Err(err).Str("line", string(line)).Msg("failed to unmarshal log line from destination plugin")
} else {
logging.JSONToLog(c.logger, structuredLogLine)
}
Expand Down
6 changes: 3 additions & 3 deletions clients/source/v0/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ func (c *Client) newManagedClient(ctx context.Context, path string) error {
break
}
if errors.Is(err, logging.ErrLogLineToLong) {
c.logger.Err(err).Str("line", string(line)).Msg("skipping too long log line")
c.logger.Info().Str("line", string(line)).Msg("truncated source plugin log line")
continue
}
if err != nil {
c.logger.Err(err).Msg("failed to read log line from plugin")
c.logger.Err(err).Msg("failed to read log line from source plugin")
break
}
var structuredLogLine map[string]any
if err := json.Unmarshal(line, &structuredLogLine); err != nil {
c.logger.Err(err).Str("line", string(line)).Msg("failed to unmarshal log line from plugin")
c.logger.Err(err).Str("line", string(line)).Msg("failed to unmarshal log line from source plugin")
} else {
logging.JSONToLog(c.logger, structuredLogLine)
}
Expand Down
7 changes: 5 additions & 2 deletions internal/logging/log_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
// logReaderPrefixLen is used when returning a partial line as context in NextLine
const logReaderPrefixLen = 1000

var ErrLogLineToLong = errors.New("log line too long, discarding")
var (
ErrLogLineToLong = errors.New("log line too long, discarding")
ellipsis = []byte("...")
)

// logReader is a custom implementation similar to bufio.Scanner, but provides a way to handle lines
// (or tokens) that exceed the buffer size.
Expand Down Expand Up @@ -52,5 +55,5 @@ func (r *LogReader) NextLine() ([]byte, error) {
return nil, err
}
}
return prefix, ErrLogLineToLong
return append(prefix, ellipsis...), ErrLogLineToLong
}
2 changes: 1 addition & 1 deletion internal/logging/log_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Test_LogReader(t *testing.T) {
name: "very long line",
text: longStr(10000000),
wantLines: []string{
longStr(logReaderPrefixLen),
longStr(logReaderPrefixLen) + "...",
},
wantErr: true,
},
Expand Down