Skip to content
Open
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
27 changes: 21 additions & 6 deletions LoggerFirmware/src/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,19 @@ uint32_t Manager::GetNextLogNumber(void)

String Manager::MakeLogName(uint32_t log_num)
{
String filename("/logs/wibl-raw.");
filename += log_num;
String filename("/logs/raw");
if (log_num >= 100000) {
// Ensure no more than eight characters in the filename
uint32_t remapped_lognum = log_num % 100000;
String logmsg = String("error: log number ") +
log_num + "passed to MakeLogName (must be < 100000) - resetting to " +
remapped_lognum + "; this may cause problems.\n";
Syslog(logmsg);
log_num = remapped_lognum;
}
char log_num_str[10];
snprintf(log_num_str, 10, "%05d.wbl", log_num);
filename.concat(log_num_str);
return filename;
}

Expand All @@ -727,14 +738,18 @@ String Manager::MakeLogName(uint32_t log_num)

int32_t Manager::ExtractLogNumber(String const& filename)
{
if (filename.indexOf(String("wibl-raw")) < 0) {
if (!filename.endsWith("wbl")) {
// This is not a log file, so converting the extension would not be useful
return -1;
}
// Since we know that it's a log file (test above) then we know that it must have an
// extension that can be converted into an integer (since they are only made by
// Since we know that it's a log file (test above) then we know that it must have a
// component that can be converted into an integer (since they are only made by
// MakeLogName() here, and therefore always have the same format)
return filename.substring(filename.indexOf('.')+1).toInt();
int start = filename.indexOf("raw") + 3,
end = filename.indexOf('.');
String filenum_str = filename.substring(start, end);
int filenum = filenum_str.toInt();
return filenum;
}

/// Output the contents of the system console log to something that implements the Stream
Expand Down