Index: src/errorLogger.cpp
===================================================================
--- src/errorLogger.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/errorLogger.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,98 @@
+/*
+ * errorLogger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#include <fstream>
+#include "errorLogger.hpp"
+#include "verbose.hpp"
+
+ofstream null("/dev/null");
+
+errorLogger* errorLogger::instance = NULL;
+int errorLogger::verbosity = 0;
+ostream* errorLogger::nix = &null;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return errorLogger instance
+ */
+errorLogger::errorLogger()
+{
+  instance = NULL;
+  verbosity = 0;
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+errorLogger::~errorLogger() {
+  verbosity = 0;
+}
+
+/**
+ * Returns the singleton errorLogger instance.
+ *
+ * \return errorLogger instance
+ */
+errorLogger* errorLogger::getInstance() {
+  if (instance == NULL) {
+    instance = new errorLogger();
+  }
+
+  return instance;
+}
+
+
+/**
+ * Purges the current errorLogger instance.
+ */
+void errorLogger::purgeInstance() {
+  if (instance != NULL) {
+    delete instance;
+  }
+
+  instance = NULL;
+}
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void errorLogger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class errorLogger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoOutput(verbosityLevel))
+    return cerr;
+  else
+    return *l.nix;
+};
+ostream& operator<<(class errorLogger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoOutput(verbosityLevel))
+    return cerr;
+  else
+    return *l->nix;
+};
+
+
Index: src/errorLogger.hpp
===================================================================
--- src/errorLogger.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/errorLogger.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,40 @@
+/*
+ * errorLogger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef ERRORLOGGER_HPP_
+#define ERRORLOGGER_HPP_
+
+#include <iostream>
+
+using namespace std;
+
+class Verbose;
+
+class errorLogger {
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static errorLogger* getInstance();
+  static void purgeInstance();
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  errorLogger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~errorLogger();
+
+private:
+  static errorLogger* instance;
+};
+
+ostream& operator<<(class errorLogger&l, const Verbose& ost);
+ostream& operator<<(class errorLogger*l, const Verbose& ost);
+
+#endif /* ERRORLOGGER_HPP_ */
Index: src/log.cpp
===================================================================
--- src/log.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/log.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,37 @@
+/*
+ * log.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#include "logger.hpp"
+#include "errorLogger.hpp"
+
+/**
+ * Sets verbosity for the error logger and the standard logger.
+ *
+ * \param int verbosity level
+ */
+void setVerbosity(int verbosityLevel) {
+  logger::getInstance()->setVerbosity(verbosityLevel);
+  errorLogger::getInstance()->setVerbosity(verbosityLevel);
+}
+
+/**
+ * Prints a log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class logger * log() {
+  return logger::getInstance();
+}
+
+/**
+ * Prints an error log entry.
+ *
+ * \param indentation level of the message to log
+ */
+class errorLogger * elog() {
+  return errorLogger::getInstance();
+}
Index: src/log.hpp
===================================================================
--- src/log.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/log.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,15 @@
+/*
+ * log.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOG_HPP_
+#define LOG_HPP_
+
+class logger * log();
+class errorLogger * elog();
+void setVerbosity(int verbosityLevel);
+
+#endif /* LOG_HPP_ */
Index: src/logger.cpp
===================================================================
--- src/logger.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/logger.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,97 @@
+/*
+ * logger.cpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#include <fstream>
+#include "logger.hpp"
+#include "verbose.hpp"
+
+ofstream nullStream("/dev/null");
+
+logger* logger::instance = NULL;
+int logger::verbosity = 0;
+ostream* logger::nix = &nullStream;
+
+/**
+ * Constructor. Do not use this function. Use getInstance() instead.
+ *
+ * \return logger instance
+ */
+logger::logger()
+{
+  instance = NULL;
+  verbosity = 0;
+};
+
+/**
+ * Destructor. Better use purgeInstance().
+ */
+logger::~logger() {
+  verbosity = 0;
+}
+
+/**
+ * Returns the singleton logger instance.
+ *
+ * \return logger instance
+ */
+logger* logger::getInstance() {
+  if (instance == NULL) {
+    instance = new logger();
+  }
+
+  return instance;
+}
+
+
+/**
+ * Purges the current logger instance.
+ */
+void logger::purgeInstance() {
+  if (instance != NULL) {
+    delete instance;
+  }
+
+  instance = NULL;
+}
+
+/**
+ * Sets the verbosity.
+ *
+ * \param verbosityLevel verbosity
+ */
+void logger::setVerbosity(int verbosityLevel) {
+  verbosity = verbosityLevel;
+}
+
+/**
+ * Operator for the Binary(arg) call.
+ * Constructs temporary a Verbose class object, wherein the Binary is stored.
+ * Then << is called, which calls Binary's print which adds the tabs and logs
+ * the stream.
+ * \param &ost stream to extend
+ * \param &m pointer to created Binary object
+ * \return &ost
+ */
+ostream& operator<<(class logger& l, const Verbose& v)
+{
+  int verbosityLevel = l.verbosity;
+  l.nix->clear();
+  if (v.DoOutput(verbosityLevel))
+    return cout;
+  else
+    return *l.nix;
+};
+ostream& operator<<(class logger* l, const Verbose& v)
+{
+  int verbosityLevel = l->verbosity;
+  l->nix->clear();
+  if (v.DoOutput(verbosityLevel))
+    return cout;
+  else
+    return *l->nix;
+};
+
Index: src/logger.hpp
===================================================================
--- src/logger.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/logger.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,40 @@
+/*
+ * logger.hpp
+ *
+ *  Created on: Oct 19, 2009
+ *      Author: metzler
+ */
+
+#ifndef LOGGER_HPP_
+#define LOGGER_HPP_
+
+#include <iostream>
+
+using namespace std;
+
+class Verbose;
+
+class logger {
+public :
+  static ostream *nix;
+  static int verbosity;
+
+  static logger* getInstance();
+  static void purgeInstance();
+  static bool DoOutput();
+  static void setVerbosity(int verbosityLevel);
+
+protected:
+  /** Do not call this constructor directly, use getInstance() instead. */
+  logger();
+  /** Do not call this destructor directly, use purgeInstance() instead. */
+  ~logger();
+
+private:
+  static logger* instance;
+};
+
+ostream& operator<<(class logger&l, const Verbose& ost);
+ostream& operator<<(class logger*l, const Verbose& ost);
+
+#endif /* LOGGER_HPP_ */
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision c4d4dfcf2b2eb619122842838b8a34fed1b278e5)
+++ src/unittests/Makefile.am	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -1,5 +1,5 @@
 INCLUDES = -I$(top_srcdir)/src
 
-noinst_PROGRAMS =  ActOnAllUnitTest AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest MemoryAllocatorUnitTest MemoryUsageObserverUnitTest VectorUnitTest
+noinst_PROGRAMS =  ActOnAllUnitTest AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest LogUnitTest MemoryAllocatorUnitTest MemoryUsageObserverUnitTest VectorUnitTest
 
 TESTS = ActOnAllUnitTest AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest VectorUnitTest
@@ -40,2 +40,7 @@
 MemoryUsageObserverUnitTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl
 MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a
+
+LogUnitTest_SOURCES = ../errorLogger.cpp ../errorLogger.hpp ../log.cpp ../log.hpp ../logger.cpp ../logger.hpp logunittest.cpp logunittest.hpp
+LogUnitTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
+LogUnitTest_LDFLAGS = $(CPPUNIT_LIBS) -ldl
+LogUnitTest_LDADD = ../libmolecuilder.a
Index: src/unittests/logunittest.cpp
===================================================================
--- src/unittests/logunittest.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/unittests/logunittest.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,73 @@
+/*
+ * logunittest.cpp
+ */
+
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "logunittest.hpp"
+#include "logger.hpp"
+#include "errorLogger.hpp"
+#include "log.hpp"
+#include "defs.hpp"
+#include "verbose.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LogTest );
+
+
+void LogTest::setUp()
+{
+};
+
+void LogTest::tearDown()
+{
+};
+
+/**
+ * UnitTest for log()
+ */
+void LogTest::logTest()
+{
+  logger::getInstance()->setVerbosity(2);
+  cout << "Verbosity level is set to 2." << endl;
+  log() << Verbose(0) << "Test level 0" << endl;
+  log() << Verbose(1) << "Test level 1" << endl;
+  log() << Verbose(2) << "Test level 2" << endl;
+  log() << Verbose(3) << "Test level 3" << endl;
+  log() << Verbose(4) << "Test level 4" << endl;
+
+  log() << Verbose(0) << "Output a log message." << endl;
+  elog() << Verbose(0) << "Output an error message." << endl;
+  setVerbosity(3);
+  log() << Verbose(4) << "This should not be printed." << endl;
+  elog() << Verbose(4) << "This should not be printed." << endl;
+};
+
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/logunittest.hpp
===================================================================
--- src/unittests/logunittest.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
+++ src/unittests/logunittest.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -0,0 +1,26 @@
+/*
+ * logunittest.hpp
+ */
+
+#ifndef LOGTEST_HPP_
+#define LOGTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+/********************************************** Test classes **************************************/
+
+class LogTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LogTest) ;
+    CPPUNIT_TEST ( logTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void logTest();
+};
+
+#endif /* LOGTEST_HPP_ */
Index: src/verbose.cpp
===================================================================
--- src/verbose.cpp	(revision c4d4dfcf2b2eb619122842838b8a34fed1b278e5)
+++ src/verbose.cpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -15,4 +15,15 @@
 };
 
+/** States whether current output message should be print or not.
+ * Compares Verbose::Verbosity against \a verbosityLevel.
+ * \param verbosityLevel given global level of verbosity
+ * \return true - do output, false - don't
+ */
+bool Verbose::DoOutput(int verbosityLevel) const
+{
+  return (verbosityLevel >= Verbosity);
+};
+
+
 /** Operator for the Verbose(arg) call.
  * Constructs temporary a Verbose class object, wherein the verbosity is stored.
@@ -26,5 +37,4 @@
   return m.print(ost);
 };
-
 
 /** Prints the tabs according to verbosity stored in the temporary constructed class.
Index: src/verbose.hpp
===================================================================
--- src/verbose.hpp	(revision c4d4dfcf2b2eb619122842838b8a34fed1b278e5)
+++ src/verbose.hpp	(revision 06c7a3b2d6ce79572856fe678ea2a178eb974a6a)
@@ -30,4 +30,5 @@
 
     ostream& print (ostream &ost) const;
+    bool DoOutput(int verbosityLevel) const;
   private:
     int Verbosity;
