Merge pull request #194 from pjft/Log-backup

Backup previous session's Log file
This commit is contained in:
Jools Wills 2017-08-02 16:49:52 +01:00 committed by GitHub
commit 44d2e7dbab
3 changed files with 11 additions and 0 deletions

View file

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

View file

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
#include <stdio.h>
#include "platform.h" #include "platform.h"
LogLevel Log::reportingLevel = LogInfo; LogLevel Log::reportingLevel = LogInfo;
@ -23,6 +24,14 @@ void Log::setReportingLevel(LogLevel level)
reportingLevel = 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() void Log::open()
{ {
file = fopen(getLogPath().c_str(), "w"); file = fopen(getLogPath().c_str(), "w");

View file

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