@@ -394,14 +394,16 @@ bool BCLog::Logger::archive(bool fImmediate, fs::path pfile_out)
394394
395395 if (fImmediate || (fArchiveDaily && ArchiveCheckDate > PrevArchiveCheckDate))
396396 {
397+ std::string rename_error_msg;
398+
397399 {
398400 std::lock_guard<std::mutex> scoped_lock (m_cs);
399401
400402 fclose (m_fileout);
401403
402404 plogfile = m_file_path;
403405
404- pfile_temp = static_cast <fs::path>(m_file_path.stem ().string () + " -" + DateTimeStrFormat (" %Y%m%d%H%M%S" , nTime) + m_file_path.extension ().string ());
406+ pfile_temp = LogArchiveDir / static_cast <fs::path>(m_file_path.stem ().string () + " -" + DateTimeStrFormat (" %Y%m%d%H%M%S" , nTime) + m_file_path.extension ().string ());
405407
406408 pfile_out = LogArchiveDir / static_cast <fs::path>((m_file_path.filename ().stem ().string () + " -" + DateTimeStrFormat (" %Y%m%d%H%M%S" , nTime)
407409 + m_file_path.filename ().extension ().string () + " .gz" ));
@@ -410,10 +412,10 @@ bool BCLog::Logger::archive(bool fImmediate, fs::path pfile_out)
410412 {
411413 fs::rename (plogfile, pfile_temp);
412414 }
413- catch (... )
415+ catch (const std::exception& e )
414416 {
415- LogPrintf ( " ERROR: Logger: archive: Failed to rename logging file\n " ) ;
416- return false ;
417+ rename_error_msg = " Failed to rename logging file: " ;
418+ rename_error_msg += e. what () ;
417419 }
418420
419421 // Re-open logging file. (This is subtly different than the flag based reopen above, because the file must be closed first, renamed for compression,
@@ -428,6 +430,12 @@ bool BCLog::Logger::archive(bool fImmediate, fs::path pfile_out)
428430 PrevArchiveCheckDate = ArchiveCheckDate;
429431 }
430432
433+ if (!rename_error_msg.empty ())
434+ {
435+ LogPrintf (" ERROR: Logger: archive: %s" , rename_error_msg);
436+ return false ;
437+ }
438+
431439 fsbridge::ifstream infile (pfile_temp, std::ios_base::in | std::ios_base::binary);
432440
433441 if (!infile)
0 commit comments