|
|
@ -83,6 +83,18 @@ LogWriterFile::~LogWriterFile() |
|
|
|
|
|
|
|
|
|
|
|
void LogWriterFile::start_log(LogType type, const char *filename) |
|
|
|
void LogWriterFile::start_log(LogType type, const char *filename) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// At this point we don't expect the file to be open, but it can happen for very fast consecutive stop & start
|
|
|
|
|
|
|
|
// calls. In that case we wait for the thread to close the file first.
|
|
|
|
|
|
|
|
lock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (_buffers[(int)type].fd() >= 0) { |
|
|
|
|
|
|
|
unlock(); |
|
|
|
|
|
|
|
system_usleep(5000); |
|
|
|
|
|
|
|
lock(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unlock(); |
|
|
|
|
|
|
|
|
|
|
|
if (type == LogType::Full) { |
|
|
|
if (type == LogType::Full) { |
|
|
|
// register the current file with the hardfault handler: if the system crashes,
|
|
|
|
// register the current file with the hardfault handler: if the system crashes,
|
|
|
|
// the hardfault handler will append the crash log to that file on the next reboot.
|
|
|
|
// the hardfault handler will append the crash log to that file on the next reboot.
|
|
|
|