|
|
@ -10,6 +10,10 @@
|
|
|
|
#include <memory>
|
|
|
|
#include <memory>
|
|
|
|
#include "Queue.h"
|
|
|
|
#include "Queue.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
#include <syslog.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
enum LogLevel
|
|
|
|
enum LogLevel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
eLogError = 0,
|
|
|
|
eLogError = 0,
|
|
|
@ -46,7 +50,12 @@ class Log: public i2p::util::MsgQueue<LogMsg>
|
|
|
|
const std::string& GetTimestamp ();
|
|
|
|
const std::string& GetTimestamp ();
|
|
|
|
LogLevel GetLogLevel () { return m_MinLevel; };
|
|
|
|
LogLevel GetLogLevel () { return m_MinLevel; };
|
|
|
|
const std::string& GetFullFilePath () const { return m_FullFilePath; };
|
|
|
|
const std::string& GetFullFilePath () const { return m_FullFilePath; };
|
|
|
|
|
|
|
|
/** start logging to syslog */
|
|
|
|
|
|
|
|
void StartSyslog(const std::string & ident, const int facility);
|
|
|
|
|
|
|
|
/** stop logging to syslog */
|
|
|
|
|
|
|
|
void StopSyslog();
|
|
|
|
|
|
|
|
/** are we logging to syslog right now? */
|
|
|
|
|
|
|
|
bool SyslogEnabled();
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
void Flush ();
|
|
|
|
void Flush ();
|
|
|
@ -62,6 +71,7 @@ class Log: public i2p::util::MsgQueue<LogMsg>
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
std::chrono::steady_clock::time_point m_LastTimestampUpdate;
|
|
|
|
std::chrono::steady_clock::time_point m_LastTimestampUpdate;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
std::string m_Ident;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern Log * g_Log;
|
|
|
|
extern Log * g_Log;
|
|
|
@ -116,6 +126,20 @@ inline bool IsLogToFile ()
|
|
|
|
return g_Log ? !g_Log->GetFullFilePath ().empty () : false;
|
|
|
|
return g_Log ? !g_Log->GetFullFilePath ().empty () : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void StartSyslog()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
StartLog("");
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
g_Log->StartSyslog("i2pd", LOG_USER);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void StopSyslog()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(g_Log)
|
|
|
|
|
|
|
|
g_Log->StopSyslog();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename TValue>
|
|
|
|
template<typename TValue>
|
|
|
|
void LogPrint (std::stringstream& s, TValue arg)
|
|
|
|
void LogPrint (std::stringstream& s, TValue arg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|