PLearn 0.1
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Friends
PLearn::PL_LogPluginInterceptor Class Reference

Forward declare. More...

#include <pl_log.h>

Inheritance diagram for PLearn::PL_LogPluginInterceptor:
Inheritance graph
[legend]
Collaboration diagram for PLearn::PL_LogPluginInterceptor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PL_LogPluginInterceptor (const set< string > &intercept_lognames, PL_LogPlugin *previous)
virtual PStreamgetStream (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_LogPluginm_previous
 Previous plugin to process log entries that are not intercepted.
LogMap m_log_entries
 Current log entries for each logname.
PP< LogInterceptorPStreamBufm_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

Detailed Description

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.

Definition at line 149 of file pl_log.h.


Member Typedef Documentation

Definition at line 151 of file pl_log.h.

typedef map< string, deque<string> > PLearn::PL_LogPluginInterceptor::LogMap [private]

Definition at line 153 of file pl_log.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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;
}

Here is the call graph for this function:

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];
}

Friends And Related Function Documentation

friend class LogInterceptorPStreamBuf [friend]

Definition at line 152 of file pl_log.h.


Member Data Documentation

List of intercepted lognames.

Definition at line 175 of file pl_log.h.

Referenced by getStream().

Current log entries for each logname.

Definition at line 181 of file pl_log.h.

Referenced by appendLog(), clearLog(), and logEntries().

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 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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines