Properly rotate logfiles on sustain.

This commit is contained in:
JoelKatz
2013-07-21 23:11:49 -07:00
parent f466fcf93b
commit 5c040e78bb
3 changed files with 7 additions and 5 deletions

View File

@@ -34,7 +34,7 @@ std::string StopSustain ()
return "Terminating monitor"; return "Terminating monitor";
} }
std::string DoSustain () std::string DoSustain (std::string logFile)
{ {
int childCount = 0; int childCount = 0;
pManager = getpid (); pManager = getpid ();
@@ -72,7 +72,9 @@ std::string DoSustain ()
while (kill (pChild, 0) == 0); while (kill (pChild, 0) == 0);
rename ("core", boost::str (boost::format ("core.%d") % static_cast<int> (pChild)).c_str ()); rename ("core", boost::str (boost::format ("core.%d") % static_cast<int> (pChild)).c_str ());
rename ("debug.log", boost::str (boost::format ("debug.log.%d") % static_cast<int> (pChild)).c_str ()); if (!logFile.empty())
rename (logFile.c_str(),
boost::str (boost::format ("%s.%d") % logFile % static_cast<int> (pChild)).c_str ());
} }
} }
@@ -82,7 +84,7 @@ bool HaveSustain ()
{ {
return false; return false;
} }
std::string DoSustain () std::string DoSustain (std::string)
{ {
return std::string (); return std::string ();
} }

View File

@@ -15,6 +15,6 @@
// //
extern bool HaveSustain (); extern bool HaveSustain ();
extern std::string StopSustain (); extern std::string StopSustain ();
extern std::string DoSustain (); extern std::string DoSustain (std::string logFile);
#endif #endif

View File

@@ -299,7 +299,7 @@ int rippleMain (int argc, char** argv)
if (HaveSustain () && if (HaveSustain () &&
!iResult && !vm.count ("parameters") && !vm.count ("fg") && !vm.count ("standalone") && !vm.count ("unittest")) !iResult && !vm.count ("parameters") && !vm.count ("fg") && !vm.count ("standalone") && !vm.count ("unittest"))
{ {
std::string logMe = DoSustain (); std::string logMe = DoSustain (theConfig.DEBUG_LOGFILE.c_str());
if (!logMe.empty ()) if (!logMe.empty ())
Log (lsWARNING) << logMe; Log (lsWARNING) << logMe;