1 |
#pragma once |
2 |
|
3 |
#include <fstream> |
4 |
|
5 |
struct logstream |
6 |
{ |
7 |
logstream (char const *file, int line, char const *func); |
8 |
~logstream (); |
9 |
|
10 |
logstream const &operator () (char const *channel = "dclient") const; |
11 |
|
12 |
static std::ofstream fh; |
13 |
|
14 |
char const *file; |
15 |
long line; |
16 |
char const *func; |
17 |
}; |
18 |
|
19 |
template<typename T> |
20 |
static inline logstream const & |
21 |
operator << (logstream const &log, T const &v) |
22 |
{ |
23 |
log.fh << v; |
24 |
return log; |
25 |
} |
26 |
|
27 |
#define LOG logstream (__FILE__, __LINE__, __func__) |