diff --git a/src/modules/logger/log_writer_file.cpp b/src/modules/logger/log_writer_file.cpp index cbcb780b7a..05993a18a9 100644 --- a/src/modules/logger/log_writer_file.cpp +++ b/src/modules/logger/log_writer_file.cpp @@ -84,6 +84,16 @@ LogWriterFile::~LogWriterFile() void LogWriterFile::start_log(const char *filename) { + // 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. + // Note that we don't deregister it when closing the log, so that crashes after disarming + // are appended as well (the same holds for crashes before arming, which can be a bit misleading) + int ret = hardfault_store_filename(filename); + + if (ret) { + PX4_ERR("Failed to register ULog file to the hardfault handler (%i)", ret); + } + _fd = ::open(filename, O_CREAT | O_WRONLY, PX4_O_MODE_666); if (_fd < 0) { @@ -104,17 +114,6 @@ void LogWriterFile::start_log(const char *filename) } } - // 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. - // Note that we don't deregister it when closing the log, so that crashes after disarming - // are appended as well (the same holds for crashes before arming, which can be a bit misleading) - int ret = hardfault_store_filename(filename); - - if (ret) { - PX4_ERR("Failed to register ULog file to the hardfault handler (%i)", ret); - } - - PX4_INFO("Opened log file: %s", filename); _should_run = true; _running = true;