mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
moved log file from daemon to log
This commit is contained in:
parent
3e81123d94
commit
2062305f88
4 changed files with 30 additions and 18 deletions
14
Log.h
14
Log.h
|
@ -1,8 +1,10 @@
|
|||
#ifndef LOG_H__
|
||||
#define LOG_H__
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include "Queue.h"
|
||||
|
||||
|
@ -20,11 +22,19 @@ class Log: public i2p::util::MsgQueue<LogMsg>
|
|||
{
|
||||
public:
|
||||
|
||||
Log () { SetOnEmpty (std::bind (&Log::Flush, this)); };
|
||||
Log (): m_LogFile (nullptr) { SetOnEmpty (std::bind (&Log::Flush, this)); };
|
||||
~Log () { delete m_LogFile; };
|
||||
|
||||
void SetLogFile (const std::string& fullFilePath);
|
||||
std::ofstream * GetLogFile () const { return m_LogFile; };
|
||||
|
||||
private:
|
||||
|
||||
void Flush ();
|
||||
|
||||
private:
|
||||
|
||||
std::ofstream * m_LogFile;
|
||||
};
|
||||
|
||||
extern Log g_Log;
|
||||
|
@ -45,7 +55,7 @@ void LogPrint (std::stringstream& s, TValue arg, TArgs... args)
|
|||
template<typename... TArgs>
|
||||
void LogPrint (TArgs... args)
|
||||
{
|
||||
LogMsg * msg = new LogMsg ();
|
||||
LogMsg * msg = g_Log.GetLogFile () ? new LogMsg (*g_Log.GetLogFile ()) : new LogMsg ();
|
||||
LogPrint (msg->s, args...);
|
||||
msg->s << std::endl;
|
||||
g_Log.Put (msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue