1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-18 00:09:58 +00:00
i2pd/Log.cpp

30 lines
637 B
C++
Raw Normal View History

2013-12-10 08:00:13 -05:00
#include "Log.h"
2014-08-17 07:35:09 +02:00
#include <boost/date_time/posix_time/posix_time.hpp>
2013-12-10 08:00:13 -05:00
2014-07-02 13:48:45 -04:00
Log * g_Log = nullptr;
void LogMsg::Process()
{
2014-08-17 07:49:29 -04:00
output << boost::posix_time::second_clock::local_time().time_of_day () << " - ";
output << s.str();
2014-04-23 12:49:02 -04:00
}
void Log::Flush ()
{
2014-04-24 11:10:46 -04:00
if (m_LogFile)
m_LogFile->flush();
2014-04-23 12:49:02 -04:00
}
2014-04-24 11:10:46 -04:00
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;
}
}