PLearn 0.1
|
Forward declare. More...
#include <pl_log.h>
Public Member Functions | |
PL_LogPluginInterceptor (const set< string > &intercept_lognames, PL_LogPlugin *previous) | |
virtual PStream & | getStream (PStream::mode_t outmode, const string &module_name, int requested_verbosity) |
const deque< string > & | logEntries (const string &logname) const |
Return the log entries accumulated so far under the given logname. | |
void | clearLog (const string &logname) |
Erase all log entries associated with given logname. | |
Protected Member Functions | |
void | appendLog (const string &logname, const string &logentry) |
Append a new log entry under given logname. | |
Protected Attributes | |
set< string > | m_intercept_lognames |
List of intercepted lognames. | |
PL_LogPlugin * | m_previous |
Previous plugin to process log entries that are not intercepted. | |
LogMap | m_log_entries |
Current log entries for each logname. | |
PP< LogInterceptorPStreamBuf > | m_streambuf |
Streambuf that's actually tasked with accumulating strings. | |
PStream | m_pstream |
PStream object that's returned by a call to getStream. | |
Private Types | |
typedef PL_LogPlugin | inherited |
typedef map< string, deque < string > > | LogMap |
Friends | |
class | LogInterceptorPStreamBuf |
Forward declare.
Interceptive version PL_LogPlugin. This plugin intercepts the requests made to specific log-names, and appends them to a list of log entries that is kept separately for each intercepted log-name. Requests that are made to other log-names are passed through to a 'chained plugin', for further processing.
typedef PL_LogPlugin PLearn::PL_LogPluginInterceptor::inherited [private] |
typedef map< string, deque<string> > PLearn::PL_LogPluginInterceptor::LogMap [private] |
PLearn::PL_LogPluginInterceptor::PL_LogPluginInterceptor | ( | const set< string > & | intercept_lognames, |
PL_LogPlugin * | previous | ||
) |
Definition at line 139 of file pl_log.cc.
References m_previous, and PLASSERT.
: m_intercept_lognames(intercept_lognames), m_previous(previous), m_streambuf(new LogInterceptorPStreamBuf(this)), m_pstream(m_streambuf) { PLASSERT( m_previous ); }
void PLearn::PL_LogPluginInterceptor::appendLog | ( | const string & | logname, |
const string & | logentry | ||
) | [protected] |
Append a new log entry under given logname.
Definition at line 181 of file pl_log.cc.
References m_log_entries.
{ m_log_entries[logname].push_back(logentry); }
void PLearn::PL_LogPluginInterceptor::clearLog | ( | const string & | logname | ) |
Erase all log entries associated with given logname.
If logname is empty, ALL entries are cleared, regardless of logname
Definition at line 172 of file pl_log.cc.
References m_log_entries.
{ if (logname.empty()) m_log_entries.clear(); else m_log_entries[logname].clear(); }
PStream & PLearn::PL_LogPluginInterceptor::getStream | ( | PStream::mode_t | outmode, |
const string & | module_name, | ||
int | requested_verbosity | ||
) | [virtual] |
Implements PLearn::PL_LogPlugin.
Definition at line 150 of file pl_log.cc.
References PLearn::PL_LogPlugin::getStream(), m_intercept_lognames, m_previous, m_pstream, m_streambuf, PLASSERT, and PLearn::PStream::setOutMode().
{ // If the module name is not intercepted, hand to previous handler PLASSERT( m_previous && m_streambuf ); if (m_intercept_lognames.find(module_name) == m_intercept_lognames.end()) return m_previous->getStream(outmode, module_name, requested_verbosity); m_pstream.setOutMode(outmode); m_streambuf->outputParameters(module_name, requested_verbosity); m_streambuf->flush(); return m_pstream; }
const deque< string > & PLearn::PL_LogPluginInterceptor::logEntries | ( | const string & | logname | ) | const |
Return the log entries accumulated so far under the given logname.
Definition at line 165 of file pl_log.cc.
References m_log_entries.
{ // May be empty -- don't barf return m_log_entries[logname]; }
friend class LogInterceptorPStreamBuf [friend] |
set<string> PLearn::PL_LogPluginInterceptor::m_intercept_lognames [protected] |
LogMap PLearn::PL_LogPluginInterceptor::m_log_entries [mutable, protected] |
Current log entries for each logname.
Definition at line 181 of file pl_log.h.
Referenced by appendLog(), clearLog(), and logEntries().
PL_LogPlugin* PLearn::PL_LogPluginInterceptor::m_previous [protected] |
Previous plugin to process log entries that are not intercepted.
Definition at line 178 of file pl_log.h.
Referenced by getStream(), and PL_LogPluginInterceptor().
PStream PLearn::PL_LogPluginInterceptor::m_pstream [protected] |
PStream object that's returned by a call to getStream.
Definition at line 187 of file pl_log.h.
Referenced by getStream().
Streambuf that's actually tasked with accumulating strings.
Definition at line 184 of file pl_log.h.
Referenced by getStream().