diff --git a/internal/hooks/loghooks.go b/internal/hooks/loghooks.go index 2ef5603..2b08d45 100644 --- a/internal/hooks/loghooks.go +++ b/internal/hooks/loghooks.go @@ -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 { diff --git a/internal/loggers/dbc_passive_logger.go b/internal/loggers/dbc_passive_logger.go index d77b357..076473b 100644 --- a/internal/loggers/dbc_passive_logger.go +++ b/internal/loggers/dbc_passive_logger.go @@ -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