]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include <sstream> | |
7 | ||
8 | typedef enum { | |
9 | CLOG_DEBUG = 0, | |
10 | CLOG_INFO = 1, | |
11 | CLOG_SEC = 2, | |
12 | CLOG_WARN = 3, | |
13 | CLOG_ERROR = 4, | |
14 | CLOG_UNKNOWN = -1, | |
15 | } clog_type; | |
16 | ||
17 | class OstreamTemp | |
18 | { | |
19 | public: | |
20 | class OstreamTempSink { | |
21 | public: | |
22 | virtual void do_log(clog_type prio, std::stringstream& ss) = 0; | |
23 | virtual ~OstreamTempSink() {} | |
24 | }; | |
25 | OstreamTemp(clog_type type_, OstreamTempSink *parent_); | |
26 | OstreamTemp(OstreamTemp &&rhs) = default; | |
27 | ~OstreamTemp(); | |
28 | ||
29 | template<typename T> | |
30 | std::ostream& operator<<(const T& rhs) | |
31 | { | |
32 | return ss << rhs; | |
33 | } | |
34 | ||
35 | private: | |
36 | clog_type type; | |
37 | OstreamTempSink *parent; | |
38 | std::stringstream ss; | |
39 | }; |