Skip to content

Commit

Permalink
Merge pull request #223 from KomodoPlatform/fix_rotate_log_crash
Browse files Browse the repository at this point in the history
fix(rotate_log): using error code to prevent abort
  • Loading branch information
Milerius authored Jun 7, 2020
2 parents 38a9ff0 + 765a9d8 commit 2c219cf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/atomic.dex.mm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ namespace atomic_dex
auto atomic_log_folder_path = get_atomic_dex_logs_folder();
auto current_log_file = get_atomic_dex_current_log_file();


if (fs::exists(current_log_file))
{
if (auto f_size = fs::file_size(current_log_file); f_size > 7777777)
Expand All @@ -1083,8 +1084,17 @@ namespace atomic_dex
{
fs::remove(current_log_file.string() + ".old");
}
fs::rename(current_log_file, current_log_file.string() + ".old");
LOG_F(INFO, "Log rotation finished, previous file size: {}", f_size);
boost::system::error_code ec;
fs::rename(current_log_file, current_log_file.string() + ".old", ec);
if (ec)
{
std::cerr << ec.message() << std::endl;
LOG_F(WARNING, "Log rotation failed {}", ec.message());
}
else
{
LOG_F(INFO, "Log rotation finished, previous file size: {}", f_size);
}
}
}
}
Expand Down

0 comments on commit 2c219cf

Please sign in to comment.