Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

utils::logging::ostream_listener Struct Reference

a listener writing on a ostream. More...

#include <log.h>

Inheritance diagram for utils::logging::ostream_listener::

utils::logging::listener utils::logging::file_listener List of all members.

Public Methods

 ostream_listener (ostream &o=cerr)
 ~ostream_listener ()
bool onMsg (const msg &msg)
 handles a individual message. More...


Public Attributes

ostream & out

Detailed Description

a listener writing on a ostream.

This class provides an implementation that writes the message onto an ostream.

Note that using this class is just a quick and dirty solution. It is not thread-safe in that if you use it with std::cerr or std::cout there is no way to synchronize accesses with other threads. On the other hand you cannot use it like these:

 int main()
 {
     ...
     // will crash!! after destruction of out
     ofstream out(filename);
     new ostream_listener(out);
     ...
     // will never close the outfile.
     new ostream_listener(new ofstream(filename));
     ...
 }
If you want to log into a file you should use a file_listener instead.


Constructor & Destructor Documentation

utils::logging::ostream_listener::ostream_listener ostream &    o = cerr
 

utils::logging::ostream_listener::~ostream_listener  
 


Member Function Documentation

bool utils::logging::ostream_listener::onMsg const msg   msg [virtual]
 

handles a individual message.

If this method returns false the message won't be handled any longer. As listener base objects are called in the order of creation you might use this to create simple message filters.

Reimplemented from utils::logging::listener.


Member Data Documentation

ostream& utils::logging::ostream_listener::out
 


The documentation for this struct was generated from the following file:
Generated on Mon Oct 22 17:03:48 2001 for rfc822 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001