Skip to content

Commit

Permalink
- log "did not find pid match for data frame" only 2 times (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakharenkodmytro authored Aug 1, 2024
1 parent 35a4fbc commit 945c9c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/hooks/loghooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ func LogInfo(logger zerolog.Logger, message string, opts ...LogOption) {
logger.Info().Ctx(c).Msg(message)
}

// LogWarn logs a warn message with the provided options.
func LogWarn(logger zerolog.Logger, message string, opts ...LogOption) {
c := applyOptions(opts)

logger.Warn().Ctx(c).Msg(message)
}

func applyOptions(opts []LogOption) context.Context {
options := &logOptions{}
for _, opt := range opts {
Expand Down
3 changes: 2 additions & 1 deletion internal/loggers/dbc_passive_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func (dpl *dbcPassiveLogger) StartScanning(ch chan<- models.SignalData) error {
}
ch <- s
} else {
dpl.logger.Warn().Msgf("did not find pid match for data frame: %s", printBytesAsHex(frame.Data))
msg := fmt.Sprintf("did not find pid match for data frame: %s", printBytesAsHex(frame.Data))
hooks.LogWarn(dpl.logger, msg, hooks.WithStopLogAfter(2))
}
// this frame won't be processed by the DBC filter
continue
Expand Down

0 comments on commit 945c9c7

Please sign in to comment.