Dv::Thread::logstream::LogFilter Class Reference

Implements Filter interface for filterstreambuf. More...

Inheritance diagram for Dv::Thread::logstream::LogFilter:
Inheritance graph
[legend]
Collaboration diagram for Dv::Thread::logstream::LogFilter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LogFilter (const std::string &path, const std::string &prefix)
 Constructor.
 LogFilter (std::ostream &stream, const std::string &prefix)
 Constructor, stream is managed by client.
 ~LogFilter ()
 Destructor.
int put (int c)
 Output a character.
int get ()
 Input a character, always fails.
int sync ()
 Flush buffers.
void close ()
 This is a noop.
void prefix (const std::string &prefix)
 Set prefix that will be printed at the start of each output line.
const std::string & prefix () const
std::ios::iostate state () const

Private Attributes

bool owner_
 True if stream was created from a path.
std::map< pthread_t, std::string > buffers_
 Each running thread has its own buffer.
std::string prefix_
std::ostream * stream_
bool lastnl_

Detailed Description

Implements Filter interface for filterstreambuf.


Constructor & Destructor Documentation

Dv::Thread::logstream::LogFilter::LogFilter ( const std::string &  path,
const std::string &  prefix 
)

Constructor.

Parameters:
path name of file on which log will be written.
prefix,: each output line will start with the current date, the id of the writing thread and the prefix string
See also:
Dv::Util::Date
Dv::Thread::logstream::LogFilter::LogFilter ( std::ostream &  stream,
const std::string &  prefix 
)

Constructor, stream is managed by client.

Parameters:
stream open output stream on which log will be written.
prefix,: each output line will start with the current date, the id of the writing thread and the prefix string
See also:
Dv::Util::Date
Dv::Thread::logstream::LogFilter::~LogFilter (  ) 

Destructor.


Member Function Documentation

int Dv::Thread::logstream::LogFilter::put ( int  c  ) 

Output a character.

Parameters:
c char to output
Returns:
c is all went well, EOF otherwise.
int Dv::Thread::logstream::LogFilter::get (  )  [inline]

Input a character, always fails.

Returns:
EOF, this is an output-only filter.
int Dv::Thread::logstream::LogFilter::sync (  ) 

Flush buffers.

Returns:
0 if ok, EOF otherwise
void Dv::Thread::logstream::LogFilter::close (  )  [inline]

This is a noop.

void Dv::Thread::logstream::LogFilter::prefix ( const std::string &  prefix  )  [inline]

Set prefix that will be printed at the start of each output line.

Parameters:
prefix to use.

References prefix_.

Referenced by Dv::Thread::logstream::prefix().

const std::string& Dv::Thread::logstream::LogFilter::prefix (  )  const [inline]
Returns:
prefix that is used on output
See also:
prefix(const std::string&)

References prefix_.

std::ios::iostate Dv::Thread::logstream::LogFilter::state (  )  const
Returns:
iostate of underlying stream

Member Data Documentation

True if stream was created from a path.

Reimplemented from Dv::Thread::Monitor.

std::map<pthread_t,std::string> Dv::Thread::logstream::LogFilter::buffers_ [private]

Each running thread has its own buffer.

Referenced by prefix().


The documentation for this class was generated from the following file:

dvthread-0.13.4 [11 December, 2009]