Dv::Thread::logstream Class Reference

A Dv::Thread::logstream is an ostream useful for logging. More...

#include <logstream.h>

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

List of all members.

Classes

class  LogFilter
 Implements Filter interface for filterstreambuf. More...

Public Member Functions

 logstream (const std::string &path, const std::string &prefix)
 Creates ofstream for path.
 logstream (std::ostream &stream, const std::string &prefix)
 Constructor.
 ~logstream ()
 Destructor.
const std::string & prefix () const
void prefix (const std::string &s)
 Set prefix.

Private Attributes

LogFilter filter_

Detailed Description

A Dv::Thread::logstream is an ostream useful for logging.

Each line is preceeded by the date, the id of the writing thread, and an application-determined identification string.

Warning:
Output is line-oriented and buffered, i.e. output will be kept until '\n' is seen, at which time the whole line (preceeded by prefix, thread and date information) will be written to the output.
This code assumes that pthread_t is a type such that t1<t2 is well-defined for two pthread_t values t1 and t2.
See also:
Dv::Util::logstream for a non-thread safe version.
Examples:

test-pool.C.


Constructor & Destructor Documentation

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

Creates ofstream for path.

The stream will be opened with mode std::ios::app, i.e. a seek to the end of the stream will be performed before each output operation.

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

Constructor.

Parameters:
stream existing stream on which output will be written.
prefix each output line will start with the date and this prefix string
Dv::Thread::logstream::~logstream (  ) 

Destructor.


Member Function Documentation

const std::string& Dv::Thread::logstream::prefix (  )  const [inline]
Returns:
current prefix that is put at the start of each line.
See also:
Dv::Thread::logstream::logstream

References filter_, and Dv::Thread::logstream::LogFilter::prefix().

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

Set prefix.

Parameters:
s prefix that is put at the start of each line.
See also:
Dv::Thread::logstream::logstream

References filter_, and Dv::Thread::logstream::LogFilter::prefix().


Member Data Documentation

Referenced by prefix().


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

dvthread-0.13.4 [11 December, 2009]