wibble
1.1
Main Page
Namespaces
Classes
Files
File List
File Members
wibble
log
stream.h
Go to the documentation of this file.
1
#ifndef WIBBLE_LOG_STREAM_H
2
#define WIBBLE_LOG_STREAM_H
3
4
#include <streambuf>
5
#include <string>
6
7
namespace
wibble {
8
namespace
log {
9
11
enum
Level
12
{
13
DEBUG
,
14
INFO
,
15
UNUSUAL
,
16
WARN
,
17
ERR
,
18
CRIT
19
};
20
22
struct
Sender
23
{
24
virtual
~Sender
() {}
30
virtual
void
send
(
Level
level,
const
std::string& msg) = 0;
31
};
32
34
class
Streambuf
:
public
std::streambuf
35
{
36
protected
:
38
static
const
Level
defaultLevel
=
INFO
;
40
std::string
line
;
42
Level
level
;
43
45
/* Note: we have to use composition instead of overloading because the
46
* sender needs to be called in the destructor, and destructors cannot call
47
* overridden methods */
48
Sender
*
sender
;
49
51
void
send
();
52
53
public
:
55
Streambuf
();
56
62
Streambuf
(
Sender
* s);
63
virtual
~Streambuf
();
64
66
void
send_partial_line
();
67
69
void
setSender
(
Sender
* s);
70
72
void
setLevel
(
const
Level
&
level
);
73
75
int
overflow
(
int
c);
76
};
77
78
std::ostream&
operator<<
(std::ostream& s,
Level
lev);
79
80
}
81
}
82
83
// vim:set ts=4 sw=4:
84
#endif
Generated on Wed Oct 23 2013 17:14:25 for wibble by
1.8.4