Core/Logging: Use config LogsDir to save log files (re-added)

This commit is contained in:
joschiwald
2012-08-04 02:55:11 +01:00
committed by Nay
parent d1b10082a2
commit af92a36e88
3 changed files with 6 additions and 4 deletions

View File

@@ -18,9 +18,10 @@
#include "AppenderFile.h"
#include "Common.h"
AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, const char* _filename, const char* _mode, bool _backup)
AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, const char* _filename, const char* _logDir, const char* _mode, bool _backup)
: Appender(id, name, APPENDER_FILE, level)
, filename(_filename)
, logDir(_logDir)
, mode(_mode)
, backup(_backup)
{
@@ -67,5 +68,5 @@ FILE* AppenderFile::OpenFile(std::string const &filename, std::string const &mod
newName.append(LogMessage::getTimeStr(time(NULL)));
rename(filename.c_str(), newName.c_str()); // no error handling... if we couldn't make a backup, just ignore
}
return fopen(filename.c_str(), mode.c_str());
return fopen((logDir + filename).c_str(), mode.c_str());
}

View File

@@ -23,7 +23,7 @@
class AppenderFile: public Appender
{
public:
AppenderFile(uint8 _id, std::string const& _name, LogLevel level, const char* filename, const char* mode, bool backup);
AppenderFile(uint8 _id, std::string const& _name, LogLevel level, const char* filename, const char* logDir, const char* mode, bool backup);
~AppenderFile();
FILE* OpenFile(std::string const& _name, std::string const& _mode, bool _backup);
@@ -31,6 +31,7 @@ class AppenderFile: public Appender
void _write(LogMessage& message);
FILE* logfile;
std::string filename;
std::string logDir;
std::string mode;
bool dynamicName;
bool backup;

View File

@@ -127,7 +127,7 @@ void Log::CreateAppenderFromConfig(const char* name)
}
uint8 id = NextAppenderId();
appenders[id] = new AppenderFile(id, name, level, filename.c_str(), mode.c_str(), backup);
appenders[id] = new AppenderFile(id, name, level, filename.c_str(), m_logsDir.c_str(), mode.c_str(), backup);
//fprintf(stdout, "Log::CreateAppenderFromConfig: Created Appender %s (%u), Type FILE, Mask %u, File %s, Mode %s\n", name, id, level, filename.c_str(), mode.c_str()); // DEBUG - RemoveMe
break;
}