20 #ifndef _TPIE_LOGSTREAM_H
21 #define _TPIE_LOGSTREAM_H
27 #ifndef __TPIE_LOGSTREAM_H__
28 #define __TPIE_LOGSTREAM_H__
30 #include <tpie/config.h>
38 virtual void log(
log_level level,
const char * message,
size_t message_size) = 0;
42 class log_stream_buf:
public std::basic_streambuf<char, std::char_traits<char> > {
44 const static size_t buff_size = 2048;
45 const static size_t max_targets = 8;
47 char m_buff[buff_size];
49 size_t m_log_target_count;
57 virtual int overflow(
int c = traits_type::eof());
62 inline void enable(
bool e) {flush(); m_enabled=e;}
63 inline bool enabled() {
return m_enabled;}
100 inline void disable(
bool d=
false) {m_buff.enable(!d);}
101 inline void enable(
bool e=
true) {m_buff.enable(e);}
102 inline bool enabled() {
return m_buff.enabled();}
123 friend logstream& operator<< (logstream& o, const logmanip<TP>& m) {
129 logstream& manip_level(logstream& tpl,
log_level p);
130 logmanip<log_level> setlevel(
log_level p);
135 #endif //__TPIE_LOGSTREAM_H__
137 #endif // _LOGSTREAM_H
A log is like a regular output stream, but it also supports messages at different priorities...
void set_level(log_level level)
Set the current level of logging.
The logmanip template is based on the omanip template from iomanip.h in the libg++ sources...
void remove_target(log_target *t)
Remove a target for the log messages.
LOG_INFORMATIONAL is used for informational messagse.
log_level
TPIE logging levels, from higest priority to lowest.
logmanip(logstream &(*f)(logstream &, TP), TP a)
Constructor.
logstream(log_level level=LOG_INFORMATIONAL)
Constructor.
void add_target(log_target *t)
Add a target for the log messages.