Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SM-1034: "WRN did not find pid match for data frame" logged to much #106

Merged
merged 1 commit into from
Aug 1, 2024
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
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))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if we want to send WARN over MQTT, but we can reduce log noise.

hooks.LogWarn(dpl.logger, msg, hooks.WithStopLogAfter(2))
}
// this frame won't be processed by the DBC filter
continue
Expand Down
Loading