PLearn 0.1
|
#include <ServerLogStreamBuf.h>
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 |
Definition at line 49 of file ServerLogStreamBuf.h.
typedef PStreamBuf PLearn::ServerLogStreamBuf::inherited [private] |
Reimplemented from PLearn::PStreamBuf.
Definition at line 54 of file ServerLogStreamBuf.h.
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(); }
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().
PStream PLearn::ServerLogStreamBuf::log [private] |
Definition at line 56 of file ServerLogStreamBuf.h.
Referenced by write_().
string PLearn::ServerLogStreamBuf::module_name [private] |
Definition at line 57 of file ServerLogStreamBuf.h.
Referenced by write_().
int PLearn::ServerLogStreamBuf::verbosity [private] |
Definition at line 58 of file ServerLogStreamBuf.h.
Referenced by write_().