Backup previous session's Log file

Always keeps one session’s log backup file.
This commit is contained in:
pjft 2017-08-01 11:34:49 +01:00
parent 6f00abbdf7
commit c150d63d54
3 changed files with 11 additions and 0 deletions

View file

@ -222,6 +222,7 @@ int main(int argc, char* argv[])
return 1;
//start the logger
Log::init();
Log::open();
LOG(LogInfo) << "EmulationStation - v" << PROGRAM_VERSION_STRING << ", built " << PROGRAM_BUILT_STRING;

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include "platform.h"
LogLevel Log::reportingLevel = LogInfo;
@ -23,6 +24,14 @@ void Log::setReportingLevel(LogLevel level)
reportingLevel = level;
}
void Log::init()
{
remove((getLogPath() + ".bak").c_str());
// rename previous log file
rename(getLogPath().c_str(), (getLogPath() + ".bak").c_str());
return;
}
void Log::open()
{
file = fopen(getLogPath().c_str(), "w");

View file

@ -24,6 +24,7 @@ public:
static std::string getLogPath();
static void flush();
static void init();
static void open();
static void close();
protected: