mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
write to log through the separate thread
This commit is contained in:
parent
164d3566e3
commit
d91691c344
4 changed files with 75 additions and 47 deletions
20
Log.h
20
Log.h
|
@ -16,6 +16,7 @@
|
|||
#include <sstream>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include "Queue.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
|
@ -56,9 +57,9 @@ namespace log {
|
|||
std::time_t m_LastTimestamp;
|
||||
char m_LastDateTime[64];
|
||||
i2p::util::Queue<std::shared_ptr<LogMsg> > m_Queue;
|
||||
volatile bool m_IsReady;
|
||||
bool m_HasColors;
|
||||
mutable std::mutex m_OutputLock;
|
||||
volatile bool m_IsRunning;
|
||||
std::thread * m_Thread;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -66,10 +67,8 @@ namespace log {
|
|||
Log (const Log &);
|
||||
const Log& operator=(const Log&);
|
||||
|
||||
/**
|
||||
* @brief process stored messages in queue
|
||||
*/
|
||||
void Process ();
|
||||
void Run ();
|
||||
void Process (std::shared_ptr<LogMsg> msg);
|
||||
|
||||
/**
|
||||
* @brief Makes formatted string from unix timestamp
|
||||
|
@ -87,6 +86,9 @@ namespace log {
|
|||
LogType GetLogType () { return m_Destination; };
|
||||
LogLevel GetLogLevel () { return m_MinLevel; };
|
||||
|
||||
void Start ();
|
||||
void Stop ();
|
||||
|
||||
/**
|
||||
* @brief Sets minimal allowed level for log messages
|
||||
* @param level String with wanted minimal msg level
|
||||
|
@ -120,12 +122,6 @@ namespace log {
|
|||
*/
|
||||
void Append(std::shared_ptr<i2p::log::LogMsg> &);
|
||||
|
||||
/** @brief Allow log output */
|
||||
void Ready() { m_IsReady = true; }
|
||||
|
||||
/** @brief Flushes the output log stream */
|
||||
void Flush();
|
||||
|
||||
/** @brief Reopen log file */
|
||||
void Reopen();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue