|
|
@ -38,9 +38,11 @@ class Log: public i2p::util::MsgQueue<LogMsg> |
|
|
|
~Log () { delete m_LogStream; }; |
|
|
|
~Log () { delete m_LogStream; }; |
|
|
|
|
|
|
|
|
|
|
|
void SetLogFile (const std::string& fullFilePath); |
|
|
|
void SetLogFile (const std::string& fullFilePath); |
|
|
|
|
|
|
|
void SetLogLevel (const std::string& level); |
|
|
|
void SetLogStream (std::ostream * logStream); |
|
|
|
void SetLogStream (std::ostream * logStream); |
|
|
|
std::ostream * GetLogStream () const { return m_LogStream; }; |
|
|
|
std::ostream * GetLogStream () const { return m_LogStream; }; |
|
|
|
const std::string& GetTimestamp (); |
|
|
|
const std::string& GetTimestamp (); |
|
|
|
|
|
|
|
LogLevel GetLogLevel () { return m_MinLevel; }; |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
@ -49,6 +51,7 @@ class Log: public i2p::util::MsgQueue<LogMsg> |
|
|
|
private: |
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
std::ostream * m_LogStream; |
|
|
|
std::ostream * m_LogStream; |
|
|
|
|
|
|
|
enum LogLevel m_MinLevel; |
|
|
|
std::string m_Timestamp; |
|
|
|
std::string m_Timestamp; |
|
|
|
#if (__GNUC__ == 4) && (__GNUC_MINOR__ <= 6) && !defined(__clang__) // gcc 4.6
|
|
|
|
#if (__GNUC__ == 4) && (__GNUC_MINOR__ <= 6) && !defined(__clang__) // gcc 4.6
|
|
|
|
std::chrono::monotonic_clock::time_point m_LastTimestampUpdate; |
|
|
|
std::chrono::monotonic_clock::time_point m_LastTimestampUpdate; |
|
|
@ -108,13 +111,14 @@ void LogPrint (std::stringstream& s, TValue arg, TArgs... args) |
|
|
|
template<typename... TArgs> |
|
|
|
template<typename... TArgs> |
|
|
|
void LogPrint (LogLevel level, TArgs... args) |
|
|
|
void LogPrint (LogLevel level, TArgs... args) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (g_Log && level > g_Log->GetLogLevel ()) |
|
|
|
|
|
|
|
return; |
|
|
|
LogMsg * msg = new LogMsg (g_Log, level); |
|
|
|
LogMsg * msg = new LogMsg (g_Log, level); |
|
|
|
LogPrint (msg->s, args...); |
|
|
|
LogPrint (msg->s, args...); |
|
|
|
msg->s << std::endl; |
|
|
|
msg->s << std::endl; |
|
|
|
if (g_Log) |
|
|
|
if (g_Log) { |
|
|
|
g_Log->Put (msg); |
|
|
|
g_Log->Put (msg); |
|
|
|
else |
|
|
|
} else { |
|
|
|
{ |
|
|
|
|
|
|
|
msg->Process (); |
|
|
|
msg->Process (); |
|
|
|
delete msg; |
|
|
|
delete msg; |
|
|
|
} |
|
|
|
} |
|
|
|