orxonox::OutputHandler Class Reference

The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell. More...

#include <src/util/OutputHandler.h>

List of all members.

Public Types

enum  OutputDevice { LD_All = 0, LD_Console = 1, LD_Logfile = 2, LD_Shell = 3 }

Public Member Functions

std::ofstream & getLogfile ()
 Returns a reference to the logfile.
OutputBuffergetOutputBuffer ()
 Returns a pointer to the OutputBuffer.
int getOutputLevel () const
 Returns the level of the incoming output.
OutputHandleroperator<< (std::ios_base &(*manipulator)(std::ios_base &))
 Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
OutputHandleroperator<< (std::ios &(*manipulator)(std::ios &))
 Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
OutputHandleroperator<< (std::ostream &(*manipulator)(std::ostream &))
 Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
OutputHandleroperator<< (std::streambuf *sb)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (bool val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (const void *val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (long double val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (double val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (float val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (unsigned long long val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (long long val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (unsigned long val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (long val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (unsigned int val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (int val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (unsigned short val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (short val)
 Overloaded << operator, redirects the output to the console and the logfile.
OutputHandleroperator<< (unsigned char val)
 Overloaded << operator, redirects the output to the console and the logfile.
template<class T>
OutputHandleroutput (const T &output)
 Redirects the output to the console and the logfile.
void setOutputBuffer (OutputBuffer *buffer)
 Sets the OutputBuffer, representing the third output stream.
OutputHandlersetOutputLevel (int level)
 Sets the level of the incoming output.

Static Public Member Functions

static const std::stringdebug (const std::string &text)
 Puts some debug output on the outstream.
static const std::stringerror (const std::string &text)
 Puts an error on the outstream.
static OutputHandlergetOutStream ()
 Returns a reference to the only existing instance of the OutputHandler class.
static int getSoftDebugLevel (OutputHandler::OutputDevice device=OutputHandler::LD_All)
 Returns the soft debug level for a given output device.
static const std::stringinfo (const std::string &text)
 Puts an info on the outstream.
static const std::stringlog (const std::string &text)
 Puts some text on the outstream.
static void setLogPath (const std::string &path)
 Sets the path where to create orxonox.log.
static void setSoftDebugLevel (OutputHandler::OutputDevice device, int level)
 Sets the soft debug level for a given output device.
static const std::stringwarning (const std::string &text)
 Puts a warning on the outstream.

Private Member Functions

 OutputHandler (const OutputHandler &oh)
 OutputHandler ()
 Constructor: Opens the logfile and writes the first line.
virtual ~OutputHandler ()
 Destructor: Writes the last line to the logfile and closes it.

Private Attributes

OutputBuffer fallbackBuffer_
 The OutputBuffer that gets used if there is no other OutputBuffer.
std::ofstream logfile_
 The logfile where the output is logged.
std::string logfilename_
 The name of the logfile.
OutputBufferoutputBuffer_
 The OutputBuffer to put output in (usually used by the Shell).
int outputLevel_
 The level of the incoming output.
int softDebugLevel_ [4]
 The soft debug level for each OutputDevice - the configurable maximal output level.


Detailed Description

The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell.

Member Enumeration Documentation

Enumerator:
LD_All 
LD_Console 
LD_Logfile 
LD_Shell 


Constructor & Destructor Documentation

orxonox::OutputHandler::OutputHandler (  )  [explicit, private]

Constructor: Opens the logfile and writes the first line.

Parameters:
logfilename The name of the logfile

References fallbackBuffer_, LD_All, LD_Console, LD_Logfile, LD_Shell, logfile_, logfilename_, outputBuffer_, and softDebugLevel_.

orxonox::OutputHandler::OutputHandler ( const OutputHandler oh  )  [private]

orxonox::OutputHandler::~OutputHandler (  )  [private, virtual]

Destructor: Writes the last line to the logfile and closes it.

References logfile_.


Member Function Documentation

static const std::string& orxonox::OutputHandler::debug ( const std::string text  )  [inline, static]

Puts some debug output on the outstream.

Parameters:
text The text

References getOutStream(), output(), and setOutputLevel().

static const std::string& orxonox::OutputHandler::error ( const std::string text  )  [inline, static]

Puts an error on the outstream.

Parameters:
text The text

References getOutStream(), output(), and setOutputLevel().

std::ofstream& orxonox::OutputHandler::getLogfile (  )  [inline]

Returns a reference to the logfile.

Returns:
The logfile

Referenced by orxonox::operator<<().

OutputBuffer* orxonox::OutputHandler::getOutputBuffer (  )  [inline]

Returns a pointer to the OutputBuffer.

Returns:
The OutputBuffer

Referenced by orxonox::operator<<().

int orxonox::OutputHandler::getOutputLevel (  )  const [inline]

Returns the level of the incoming output.

Returns:
The level

Referenced by orxonox::Shell::addLine(), and orxonox::operator<<().

OutputHandler & orxonox::OutputHandler::getOutStream (  )  [static]

int orxonox::OutputHandler::getSoftDebugLevel ( OutputHandler::OutputDevice  device = OutputHandler::LD_All  )  [static]

Returns the soft debug level for a given output device.

Parameters:
device The output device
Returns:
The debug level

References getOutStream(), and softDebugLevel_.

Referenced by operator<<(), and output().

static const std::string& orxonox::OutputHandler::info ( const std::string text  )  [inline, static]

Puts an info on the outstream.

Parameters:
text The text

References getOutStream(), output(), and setOutputLevel().

static const std::string& orxonox::OutputHandler::log ( const std::string text  )  [inline, static]

Puts some text on the outstream.

Parameters:
text The text

References getOutStream(), output(), and setOutputLevel().

OutputHandler & orxonox::OutputHandler::operator<< ( std::ios_base &(*)(std::ios_base &)  manipulator  ) 

Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.

Parameters:
manipulator A function, manipulating the outstream.
Returns:
A reference to the OutputHandler itself

References getSoftDebugLevel(), LD_Console, LD_Logfile, LD_Shell, logfile_, outputBuffer_, and outputLevel_.

OutputHandler & orxonox::OutputHandler::operator<< ( std::ios &(*)(std::ios &)  manipulator  ) 

Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.

Parameters:
manipulator A function, manipulating the outstream.
Returns:
A reference to the OutputHandler itself

References getSoftDebugLevel(), LD_Console, LD_Logfile, LD_Shell, logfile_, outputBuffer_, and outputLevel_.

OutputHandler & orxonox::OutputHandler::operator<< ( std::ostream &(*)(std::ostream &)  manipulator  ) 

Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.

Parameters:
manipulator A function, manipulating the outstream.
Returns:
A reference to the OutputHandler itself

References getSoftDebugLevel(), LD_Console, LD_Logfile, LD_Shell, logfile_, outputBuffer_, and outputLevel_.

OutputHandler & orxonox::OutputHandler::operator<< ( std::streambuf *  sb  ) 

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
sb The streambuffer that should be shown in the console
Returns:
A reference to the OutputHandler itself

References getSoftDebugLevel(), LD_Console, LD_Logfile, LD_Shell, logfile_, outputBuffer_, and outputLevel_.

OutputHandler& orxonox::OutputHandler::operator<< ( bool  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( const void *  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( long double  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( double  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( float  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( unsigned long long  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( long long  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( unsigned long  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( long  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( unsigned int  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( int  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( unsigned short  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( short  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

OutputHandler& orxonox::OutputHandler::operator<< ( unsigned char  val  )  [inline]

Overloaded << operator, redirects the output to the console and the logfile.

Parameters:
val The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

template<class T>
OutputHandler & orxonox::OutputHandler::output ( const T &  output  )  [inline]

Redirects the output to the console and the logfile.

Parameters:
output The value that should be shown in the console
Returns:
A reference to the OutputHandler itself

References getSoftDebugLevel(), LD_Console, LD_Logfile, LD_Shell, logfile_, outputBuffer_, and outputLevel_.

Referenced by debug(), error(), info(), log(), and warning().

void orxonox::OutputHandler::setLogPath ( const std::string path  )  [static]

Sets the path where to create orxonox.log.

Parameters:
Path string with trailing slash

References getOutStream(), logfile_, and logfilename_.

Referenced by orxonox::Core::Core().

void orxonox::OutputHandler::setOutputBuffer ( OutputBuffer buffer  ) 

Sets the OutputBuffer, representing the third output stream.

Parameters:
buffer The OutputBuffer

References fallbackBuffer_, orxonox::OutputBuffer::getStream(), and outputBuffer_.

Referenced by orxonox::Shell::Shell(), and orxonox::Shell::~Shell().

OutputHandler& orxonox::OutputHandler::setOutputLevel ( int  level  )  [inline]

Sets the level of the incoming output.

Parameters:
level The level of the incoming output
Returns:
The OutputHandler itself

Referenced by orxonox::Shell::addLine(), debug(), error(), info(), log(), orxonox::CEGUILogger::logEvent(), orxonox::GraphicsManager::messageLogged(), and warning().

void orxonox::OutputHandler::setSoftDebugLevel ( OutputHandler::OutputDevice  device,
int  level 
) [static]

Sets the soft debug level for a given output device.

Parameters:
device The output device
level The debug level

References getOutStream(), and softDebugLevel_.

Referenced by orxonox::CoreConfiguration::debugLevelChanged(), and orxonox::Core::setSoftDebugLevel().

static const std::string& orxonox::OutputHandler::warning ( const std::string text  )  [inline, static]

Puts a warning on the outstream.

Parameters:
text The text

References getOutStream(), output(), and setOutputLevel().


Member Data Documentation

The OutputBuffer that gets used if there is no other OutputBuffer.

Referenced by OutputHandler(), and setOutputBuffer().

std::ofstream orxonox::OutputHandler::logfile_ [private]

The logfile where the output is logged.

Referenced by operator<<(), output(), OutputHandler(), setLogPath(), and ~OutputHandler().

The name of the logfile.

Referenced by OutputHandler(), and setLogPath().

The OutputBuffer to put output in (usually used by the Shell).

Referenced by operator<<(), output(), OutputHandler(), and setOutputBuffer().

The level of the incoming output.

Referenced by operator<<(), and output().

The soft debug level for each OutputDevice - the configurable maximal output level.

Referenced by getSoftDebugLevel(), OutputHandler(), and setSoftDebugLevel().


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

Generated on Tue Jul 28 16:22:51 2009 for Orxonox by  doxygen 1.5.6