forked from PurpleI2P/i2pd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.h
45 lines (36 loc) · 728 Bytes
/
Log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef LOG_H__
#define LOG_H__
#include <iostream>
#include <sstream>
#include "Queue.h"
struct LogMsg
{
std::stringstream s;
std::ostream& output;
LogMsg (std::ostream& o = std::cout): output (o) {};
void Process ()
{
output << s.str ();
}
};
extern i2p::util::MsgQueue<LogMsg> g_Log;
template<typename TValue>
void LogPrint (std::stringstream& s, TValue arg)
{
s << arg;
}
template<typename TValue, typename... TArgs>
void LogPrint (std::stringstream& s, TValue arg, TArgs... args)
{
LogPrint (s, arg);
LogPrint (s, args...);
}
template<typename... TArgs>
void LogPrint (TArgs... args)
{
LogMsg * msg = new LogMsg ();
LogPrint (msg->s, args...);
msg->s << std::endl;
g_Log.Put (msg);
}
#endif