libmoost
moost::logging::pseudo_ostream Class Reference

A pseudo stream acts as an abstraction to a normal ostream. More...

#include <pseudo_ostream.hpp>

List of all members.

Public Types

typedef std::ostream &(* iomanip_t )(std::ostream &)
 IO manipulators need special handling when streaming.

Public Member Functions

 pseudo_ostream ()
void attach (std::ostream &out)
 Assign a (new) ostream.
void detach ()
 Detach current ostream.
template<typename T >
pseudo_ostreamoperator<< (T const &t)
 Allow streaming of any type.
pseudo_ostreamoperator<< (iomanip_t const &iomanip)
 operator void * () const
 A quick way to check stream is still ok.

Private Attributes

std::ostream * pout_
boost::mutex mtx_

Detailed Description

A pseudo stream acts as an abstraction to a normal ostream.

Since a logger can't log its own failures (at least it's probably not the best thing to try) the logging framework can be assigned an ostream that will be used to log any status/error messages. This ostream will be wrapped by the pseudo ostream class, which will provide thread synchronisation when writing. Also, if no ostream is provided it will silently ignore writes.

Definition at line 52 of file pseudo_ostream.hpp.


Member Typedef Documentation

typedef std::ostream&(* moost::logging::pseudo_ostream::iomanip_t)(std::ostream &)

IO manipulators need special handling when streaming.

Parameters:
iomanip: An IO manipulator
Returns:
A reference to *this

Definition at line 103 of file pseudo_ostream.hpp.


Constructor & Destructor Documentation

Definition at line 55 of file pseudo_ostream.hpp.


Member Function Documentation

void moost::logging::pseudo_ostream::attach ( std::ostream &  out) [inline]

Assign a (new) ostream.

Parameters:
out: a reference to an output stream

Definition at line 62 of file pseudo_ostream.hpp.

Detach current ostream.

Definition at line 71 of file pseudo_ostream.hpp.

moost::logging::pseudo_ostream::operator void * ( ) const [inline]

A quick way to check stream is still ok.

Returns:
null if bad/fail else !null

Definition at line 120 of file pseudo_ostream.hpp.

template<typename T >
pseudo_ostream& moost::logging::pseudo_ostream::operator<< ( T const &  t) [inline]

Allow streaming of any type.

Template Parameters:
T: the type to be streamed
Parameters:
t: the object to be streamed
Returns:
A reference to *this

Definition at line 85 of file pseudo_ostream.hpp.

pseudo_ostream& moost::logging::pseudo_ostream::operator<< ( iomanip_t const &  iomanip) [inline]

Definition at line 104 of file pseudo_ostream.hpp.


Member Data Documentation

boost::mutex moost::logging::pseudo_ostream::mtx_ [mutable, private]

Definition at line 128 of file pseudo_ostream.hpp.

std::ostream* moost::logging::pseudo_ostream::pout_ [private]

Definition at line 127 of file pseudo_ostream.hpp.


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