Orxonox: orxonox::OutputHandler Class Reference

# 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.
OutputBuffer * | getOutputBuffer ()
| Returns a pointer to the OutputBuffer.
int | getOutputLevel () const
| Returns the level of the incoming output.
OutputHandler & | operator<< (std::ios_base &(*manipulator)(std::ios_base &))
| Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
OutputHandler & | operator<< (std::ios &(*manipulator)(std::ios &))
| Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
OutputHandler & | operator<< (std::ostream &(*manipulator)(std::ostream &))
| Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
OutputHandler & | operator<< (std::streambuf *sb)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (bool val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (const void *val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (long double val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (double val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (float val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (unsigned long long val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (long long val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (unsigned long val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (long val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (unsigned int val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (int val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (unsigned short val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (short val)
| Overloaded << operator, redirects the output to the console and the logfile.
OutputHandler & | operator<< (unsigned char val)
| Overloaded << operator, redirects the output to the console and the logfile.
template<class T>
OutputHandler & | output (const T &output)
| Redirects the output to the console and the logfile.
void | setOutputBuffer (OutputBuffer *buffer)
| Sets the OutputBuffer, representing the third output stream.
OutputHandler & | setOutputLevel (int level)
| Sets the level of the incoming output.

## Static Public Member Functions

static const std::string & | debug (const std::string &text)
| Puts some debug output on the outstream.
static const std::string & | error (const std::string &text)
| Puts an error on the outstream.
static OutputHandler & | getOutStream ()
| 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::string & | info (const std::string &text)
| Puts an info on the outstream.
static const std::string & | log (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::string & | warning (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.
OutputBuffer * | outputBuffer_
| 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

enum orxonox::OutputHandler::OutputDevice

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]`

Returns a reference to the only existing instance of the OutputHandler class.

Returns:
  The instance

Referenced by orxonox::Shell::addLine(), orxonox::Core::Core(), debug(), error(), getSoftDebugLevel(), info(), log(), orxonox::CEGUILogger::logEvent(), orxonox::GraphicsManager::messageLogged(), orxonox::Shell::outputChanged(), setLogPath(), setSoftDebugLevel(), orxonox::Shell::Shell(), warning(), and orxonox::Shell::~Shell().

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

OutputBuffer orxonox::OutputHandler::fallbackBuffer_`[private]`

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().

std::string orxonox::OutputHandler::logfilename_`[private]`

The name of the logfile.

Referenced by OutputHandler(), and setLogPath().

OutputBuffer* orxonox::OutputHandler::outputBuffer_`[private]`

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

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

int orxonox::OutputHandler::outputLevel_`[private]`

The level of the incoming output.

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

int orxonox::OutputHandler::softDebugLevel_[4]`[private]`

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:

- src/util/OutputHandler.h
- src/util/OutputHandler.cc