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

Prevent empty messages from spamming the console. #164

Merged
merged 1 commit into from
Aug 26, 2020
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
11 changes: 10 additions & 1 deletion log/src/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ bool Log::Implementation::InsertMessage(
const void *_data,
const std::size_t _len)
{
// \todo Record and playback empty messages. A topic could publish an
// Int32 or Int64 message with data=0. In this situation the protobuf
// message has size zero. While this is not a problem for protobuf messages,
// it is considered an error for SQLite3. We short circuit here in order to
// prevent the final LERR in this function from spamming the console.
if (_len == 0)
return false;

int returnCode;
const std::string sql =
"INSERT INTO messages (time_recv, message, topic_id)"
Expand Down Expand Up @@ -366,7 +374,8 @@ bool Log::Implementation::InsertMessage(
returnCode = sqlite3_step(statement.Handle());
if (returnCode != SQLITE_DONE)
{
LERR("Failed to insert message: " << returnCode << "\n");
LERR("Failed to insert message. sqlite3 return code[" << returnCode
<< "] data[" << _data << "] len[" << _len << "]\n");
return false;
}
return true;
Expand Down
3 changes: 2 additions & 1 deletion log/src/Recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ void Recorder::Implementation::WriteToLogFile(const LogData &_logData)
reinterpret_cast<const void *>(_logData.msgData.data()),
_logData.msgData.size()))
{
LWRN("Failed to insert message into log file\n");
LWRN("Failed to insert message into log file from topic["
<< _logData.msgInfo.Topic() << "]\n");
}
// TODO(anyone) It would be nice for testing to simulate long delays
// associated with disk writes. In the mean time, a sleep can be added here
Expand Down