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

#include <ServerLogStreamBuf.h>

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

List of all members.

Public Member Functions

 ServerLogStreamBuf (PStream log_, const string &module_name_="", int verbosity_=0)
virtual ~ServerLogStreamBuf ()

Protected Member Functions

virtual streamsize read_ (char *p, streamsize n)
 reads up to n characters into p You should override this call in subclasses.
virtual void write_ (const char *p, streamsize n)
 writes exactly n characters from p (unbuffered, must flush)

Private Types

typedef PStreamBuf inherited

Private Attributes

PStream log
string module_name
int verbosity

Detailed Description

Definition at line 49 of file ServerLogStreamBuf.h.


Member Typedef Documentation

Reimplemented from PLearn::PStreamBuf.

Definition at line 54 of file ServerLogStreamBuf.h.


Constructor & Destructor Documentation

PLearn::ServerLogStreamBuf::ServerLogStreamBuf ( PStream  log_,
const string &  module_name_ = "",
int  verbosity_ = 0 
)

Definition at line 45 of file ServerLogStreamBuf.cc.

    : PStreamBuf(false, true, 4096, 4096), 
      log(log_), module_name(module_name_), verbosity(verbosity_)
{}
PLearn::ServerLogStreamBuf::~ServerLogStreamBuf ( ) [virtual]

Definition at line 50 of file ServerLogStreamBuf.cc.

References PLearn::PStreamBuf::flush().

{
    flush();
}

Here is the call graph for this function:


Member Function Documentation

ServerLogStreamBuf::streamsize PLearn::ServerLogStreamBuf::read_ ( char *  p,
streamsize  n 
) [protected, virtual]

reads up to n characters into p You should override this call in subclasses.

Default version issues a PLERROR

On success, the number of bytes read is returned. Zero indicates end of file. If we are not at end of file, at least one character should be returned (the call must block until at least one char is available). It is not an error if the number returned is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal). If an error occurs, an exception should be thrown.

Reimplemented from PLearn::PStreamBuf.

Definition at line 55 of file ServerLogStreamBuf.cc.

References PLERROR.

{
    PLERROR("ServerLogStreamBuf::read_ should never be used!");
    return 0; // never reached 
}
void PLearn::ServerLogStreamBuf::write_ ( const char *  p,
streamsize  n 
) [protected, virtual]

writes exactly n characters from p (unbuffered, must flush)

Reimplemented from PLearn::PStreamBuf.

Definition at line 62 of file ServerLogStreamBuf.cc.

References PLearn::PStream::flush(), log, module_name, verbosity, and PLearn::PStream::write().

{
    log.write("*L "); 
    string msg(p, n);
    log << module_name << verbosity << msg;
    log.flush();
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 56 of file ServerLogStreamBuf.h.

Referenced by write_().

Definition at line 57 of file ServerLogStreamBuf.h.

Referenced by write_().

Definition at line 58 of file ServerLogStreamBuf.h.

Referenced by write_().


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