moved log file from daemon to log

This commit is contained in:
orignal 2014-04-24 11:10:46 -04:00
parent 3e81123d94
commit 2062305f88
4 changed files with 30 additions and 18 deletions

23
Log.cpp
View file

@ -1,20 +1,29 @@
#include "Log.h"
#include "Daemon.h"
Log g_Log;
void LogMsg::Process()
{
if (Daemon.isLogging == 1 && Daemon.logfile.is_open())
Daemon.logfile << s.str();
output << s.str();
std::cout << s.str (); // TODO: delete later
}
void Log::Flush ()
{
if (Daemon.isLogging == 1 && Daemon.logfile.is_open())
Daemon.logfile.flush();
if (m_LogFile)
m_LogFile->flush();
}
void Log::SetLogFile (const std::string& fullFilePath)
{
if (m_LogFile) delete m_LogFile;
m_LogFile = new std::ofstream (fullFilePath, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);
if (m_LogFile->is_open ())
LogPrint("Logging to file ", fullFilePath, " enabled.");
else
{
delete m_LogFile;
m_LogFile = nullptr;
}
}