Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Safir::Application::Tracer Class Reference

A class for trace logging. More...

#include <Safir/Application/Tracer.h>

Public Types

typedef std::basic_ostream
< wchar_t, std::char_traits
< wchar_t > > 
stream_type
 

Public Member Functions

 Tracer (const std::wstring &prefix)
 Constructor. More...
 
 ~Tracer ()
 Destructor. More...
 
void Enable (const bool enabled)
 Turn logging of this prefix on or off. More...
 
bool IsEnabled () const
 Check whether this prefix is enabled or not. More...
 
const Traceroperator<< (stream_type &(*_Pfn)(stream_type &)) const
 Output operator for io manipulators. More...
 
const Traceroperator<< (std::ios_base &(*_Pfn)(std::ios_base &)) const
 Output operator for io manipulators. More...
 
const Traceroperator<< (ios_type &(*_Pfn)(ios_type &)) const
 Output operator for io manipulators. More...
 
template<class T >
const Traceroperator<< (const T &data) const
 Output operator for data. More...
 
stream_typestream () const
 Get the underlying ostream of the logger. More...
 

Detailed Description

A class for trace logging.

Member Typedef Documentation

typedef std::basic_ostream<wchar_t, std::char_traits<wchar_t> > Safir::Application::Tracer::stream_type

Constructor & Destructor Documentation

Safir::Application::Tracer::Tracer ( const std::wstring &  prefix)
explicit

Constructor.

Create a logger with a certain prefix.

Parameters
prefix[in] The prefix for this logger.
Safir::Application::Tracer::~Tracer ( )

Destructor.

Member Function Documentation

void Safir::Application::Tracer::Enable ( const bool  enabled)

Turn logging of this prefix on or off.

Parameters
enabled[in] The state to set logging to.
bool Safir::Application::Tracer::IsEnabled ( ) const

Check whether this prefix is enabled or not.

Returns
True if logging of this prefix is enabled.
const Tracer& Safir::Application::Tracer::operator<< ( stream_type &(*)(stream_type &)  _Pfn) const

Output operator for io manipulators.

Checks whether the prefix is enabled before executing the function.

const Tracer& Safir::Application::Tracer::operator<< ( std::ios_base &(*)(std::ios_base &)  _Pfn) const

Output operator for io manipulators.

Checks whether the prefix is enabled before executing the function.

const Tracer& Safir::Application::Tracer::operator<< ( ios_type &(*)(ios_type &)  _Pfn) const

Output operator for io manipulators.

Checks whether the prefix is enabled before executing the function.

template<class T >
const Tracer& Safir::Application::Tracer::operator<< ( const T &  data) const

Output operator for data.

Checks whether the prefix is enabled before performing the output.

stream_type& Safir::Application::Tracer::stream ( ) const

Get the underlying ostream of the logger.

Since the tracer is not an ostream itself it is sometimes desirable to get the underlying ostream to be able to pass to existing functions that take ostreams as argument. Note however that the checks for whether the prefix is enabled are not performed within this stream! So to use this reliably you need to surround the use of the stream with checks to see if the prefix is enabled or not.

Returns
The underlying ostream of the tracer.