1
// Copyright � 2003, Timothy M. Shead
3
// Contact: tshead@k-3d.com
5
// This program is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU General Public
7
// License as published by the Free Software Foundation; either
8
// version 2 of the License, or (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// General Public License for more details.
15
// You should have received a copy of the GNU General Public
16
// License along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef ___logging_streambufs_Loaded___
21
#define ___logging_streambufs_Loaded___
28
START_NAMESPACE( Aqsis )
30
///////////////////////////////////////////////////////////
33
/// When attached to an output stream, prefixes every line of output with a timestamp
38
timestamp_buf(std::ostream& Stream);
46
std::ostream& m_stream;
47
std::streambuf* const m_streambuf;
48
bool m_start_new_line;
51
///////////////////////////////////////////////////////////
54
/// When attached to an output stream, prefixes every line of output with its log-level (if any)
55
class show_level_buf :
59
show_level_buf(std::ostream& Stream);
67
std::ostream& m_stream;
68
std::streambuf* const m_streambuf;
69
bool m_start_new_line;
72
///////////////////////////////////////////////////////////
73
// fold_duplicates_buf
75
/// When attached to an output stream, replaces duplicate lines of output with a message indicating the number of duplicates
76
class fold_duplicates_buf :
80
fold_duplicates_buf(std::ostream& Stream);
81
~fold_duplicates_buf();
88
bool print_duplicates();
90
std::ostream& m_stream;
91
std::streambuf* const m_streambuf;
93
std::string m_last_buffer;
94
unsigned long m_duplicate_count;
97
///////////////////////////////////////////////////////////
100
/// When attached to an output stream, resets the log level to "unknown" after every line of output
101
class reset_level_buf :
102
public std::streambuf
105
reset_level_buf(std::ostream& Stream);
113
std::ostream& m_stream;
114
std::streambuf* const m_streambuf;
117
///////////////////////////////////////////////////////////
118
// filter_by_level_buf
120
/// Enumerates available log levels
130
/// When attached to an output stream, filters-out messages below the given level
131
class filter_by_level_buf :
132
public std::streambuf
135
filter_by_level_buf(const log_level_t MinimumLevel, std::ostream& Stream);
136
~filter_by_level_buf();
143
std::ostream& m_stream;
144
std::streambuf* const m_streambuf;
145
const log_level_t m_minimum_level;
148
///////////////////////////////////////////////////////////
151
/// When attached to an output stream, copies output to the system log
153
public std::streambuf
156
syslog_buf(std::ostream& Stream);
164
void write_to_system_log(const std::string& Message);
166
std::ostream& m_stream;
167
std::streambuf* const m_streambuf;
168
std::string m_buffer;
171
//-----------------------------------------------------------------------
173
END_NAMESPACE( Aqsis )
175
#endif // ___logging_streambufs_Loaded___