From ad883f8a798e71a2591937b4386f6a8854a7d5ed Mon Sep 17 00:00:00 2001 From: David St-Onge Date: Sun, 10 Sep 2017 22:47:20 -0400 Subject: [PATCH] addition of 5 historic logs to preserve --- src/roscontroller.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/roscontroller.cpp b/src/roscontroller.cpp index bed9e10..49ceb38 100644 --- a/src/roscontroller.cpp +++ b/src/roscontroller.cpp @@ -52,9 +52,11 @@ roscontroller::roscontroller(ros::NodeHandle &n_c, ros::NodeHandle &n_c_priv) path = path.substr(0, bzzfile_name.find_last_of("\\/"))+"/log/"; std::string folder_check="mkdir -p "+path; system(folder_check.c_str()); - rename((path +"logger_"+ std::to_string((uint8_t)robot_id)+".log").c_str(), - (path +"logger_"+ std::to_string((uint8_t)robot_id)+"_old.log").c_str()); - path += "logger_"+std::to_string(robot_id)+".log"; + for(int i=5;i>0;i--){ + rename((path +"logger_"+ std::to_string((uint8_t)robot_id)+"_"+std::to_string(i-1)+".log").c_str(), + (path +"logger_"+ std::to_string((uint8_t)robot_id)+"_"+std::to_string(i)+".log").c_str()); + } + path += "logger_"+std::to_string(robot_id)+"_0.log"; log.open(path.c_str(), std::ios_base::trunc | std::ios_base::out); }