Index: code/trunk/src/libraries/util/output/AdditionalContextListener.h
===================================================================
--- code/trunk/src/libraries/util/output/AdditionalContextListener.h	(revision 9550)
+++ code/trunk/src/libraries/util/output/AdditionalContextListener.h	(revision 9550)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup Output
+    @brief Declaration of the AdditionalContextListener interface
+*/
+
+#ifndef _AdditionalContextListener_H__
+#define _AdditionalContextListener_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <vector>
+
+#include "OutputDefinitions.h"
+
+namespace orxonox
+{
+    /**
+        @brief AdditionalContextListener is an interface which is used to notify OutputManager about additional contexts in OutputListeners
+    */
+    class _UtilExport AdditionalContextListener
+    {
+        public:
+            virtual ~AdditionalContextListener() {}
+
+            virtual void updatedLevelMask(const OutputListener* listener) = 0;
+            virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) = 0;
+            virtual void updatedAdditionalContextsMask(const OutputListener* listener) = 0;
+    };
+}
+
+#endif /* _AdditionalContextListener_H__ */
Index: code/trunk/src/libraries/util/output/ConsoleWriter.cc
===================================================================
--- code/trunk/src/libraries/util/output/ConsoleWriter.cc	(revision 9348)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.cc	(revision 9550)
@@ -34,5 +34,4 @@
 #include "ConsoleWriter.h"
 
-#include <iostream>
 
 #include "OutputManager.h"
@@ -48,5 +47,5 @@
         After creation, the instance is enabled.
     */
-    ConsoleWriter::ConsoleWriter() : BaseWriter("Console")
+    ConsoleWriter::ConsoleWriter(std::ostream& outputStream) : BaseWriter("Console"), outputStream_(outputStream)
     {
 #ifdef ORXONOX_RELEASE
@@ -66,18 +65,9 @@
 
     /**
-        @brief Returns the only existing instance of this class.
-    */
-    /*static*/ ConsoleWriter& ConsoleWriter::getInstance()
-    {
-        static ConsoleWriter instance;
-        return instance;
-    }
-
-    /**
         @brief Inherited function from BaseWriter, writes output to the console using std::cout.
     */
     void ConsoleWriter::printLine(const std::string& line, OutputLevel)
     {
-        std::cout << line << std::endl;
+        this->outputStream_ << line << std::endl;
     }
 
Index: code/trunk/src/libraries/util/output/ConsoleWriter.h
===================================================================
--- code/trunk/src/libraries/util/output/ConsoleWriter.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.h	(revision 9550)
@@ -37,4 +37,7 @@
 
 #include "util/UtilPrereqs.h"
+
+#include <ostream>
+
 #include "BaseWriter.h"
 
@@ -44,14 +47,18 @@
         @brief ConsoleWriter inherits from BaseWriter and writes output to the console.
 
-        This class can be seen as an equivalent to std::cout within the output
-        system. It is implemented as a singleton for static acces.
+        This class can be seen as an equivalent to std::cout within the output system.
     */
     class _UtilExport ConsoleWriter : public BaseWriter
     {
         public:
-            static ConsoleWriter& getInstance();
+            ConsoleWriter(std::ostream& outputStream);
+            ConsoleWriter(const ConsoleWriter&);
+            virtual ~ConsoleWriter();
 
             void enable();
             void disable();
+
+            inline const std::ostream& getOutputStream() const
+                { return this->outputStream_; }
 
         protected:
@@ -59,9 +66,6 @@
 
         private:
-            ConsoleWriter();
-            ConsoleWriter(const ConsoleWriter&);
-            virtual ~ConsoleWriter();
-
-            bool bEnabled_; ///< If false, the instance will not write output to the console.
+            std::ostream& outputStream_; ///< The ostream to which the console writer writes its output
+            bool bEnabled_;              ///< If false, the instance will not write output to the console.
     };
 }
Index: code/trunk/src/libraries/util/output/LogWriter.cc
===================================================================
--- code/trunk/src/libraries/util/output/LogWriter.cc	(revision 9348)
+++ code/trunk/src/libraries/util/output/LogWriter.cc	(revision 9550)
@@ -39,7 +39,10 @@
 #include "OutputManager.h"
 #include "MemoryWriter.h"
+#include "util/Convert.h"
 
 namespace orxonox
 {
+    static const int MAX_ARCHIVED_FILES = 9;
+
     /**
         @brief Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.
@@ -58,9 +61,11 @@
         // get the path for a temporary file, depending on the system
 #ifdef ORXONOX_PLATFORM_WINDOWS
-        this->path_ = getenv("TEMP");
+        this->directory_ = getenv("TEMP");
 #else
-        this->path_ = "/tmp";
+        this->directory_ = "/tmp";
 #endif
-        this->bDefaultPath_ = true;
+
+        // send a message to the user so that he can find the file in the case of a crash.
+        OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + this->getPath());
 
         this->openFile();
@@ -76,26 +81,13 @@
 
     /**
-        @brief Returns the only existing instance of this class.
-    */
-    /*static*/ LogWriter& LogWriter::getInstance()
-    {
-        static LogWriter instance;
-        return instance;
-    }
-
-    /**
         @brief Opens the log-file in order to write output to it.
     */
     void LogWriter::openFile()
     {
-        // get the full file-name
-        std::string name = this->path_ + '/' + this->filename_;
-
-        // if we open the log file in the default directory, send a message to the user so that he can find the file in the case of a crash.
-        if (this->bDefaultPath_)
-            OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + name);
+        // archive the old log file
+        this->archive();
 
         // open the file
-        this->file_.open(name.c_str(), std::fstream::out);
+        this->file_.open(this->getPath().c_str(), std::fstream::out);
 
         // check if it worked and print some output
@@ -119,19 +111,63 @@
 
     /**
+     * @brief Archives old copies of the log file by adding increasing numbers to the filename.
+     */
+    void LogWriter::archive(int index)
+    {
+        std::string oldPath = this->getArchivedPath(index);
+
+        // see if the file already exists, otherwise return
+        std::ifstream stream(oldPath.c_str());
+        bool exists = stream.is_open();
+        stream.close();
+
+        if (!exists)
+            return;
+
+        if (index < MAX_ARCHIVED_FILES)
+        {
+            // increment the index and archive the file with the next higher index
+            this->archive(++index);
+
+            // create the new path based on the incremented index
+            std::string newPath = this->getArchivedPath(index);
+
+            // move the file
+            std::rename(oldPath.c_str(), newPath.c_str());
+        }
+        else
+        {
+            // delete the file
+            std::remove(oldPath.c_str());
+        }
+    }
+    
+    /**
+     * @brief Returns the path for archived copies of the logfile (based on the archive index)
+     */
+    std::string LogWriter::getArchivedPath(int index) const
+    {
+        std::string path = this->getPath();
+        if (index > 0)
+            path += '.' + multi_cast<std::string>(index);
+        return path;
+    }
+
+    /**
         @brief Changes the path of the log-file. Re-writes the log-file by using MemoryWriter.
     */
-    void LogWriter::setLogPath(const std::string& path)
+    void LogWriter::setLogDirectory(const std::string& directory)
     {
         // notify about the change of the log-file (because the old file will no longer be updated)
-        OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->path_ + "\nto " + path);
+        OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->directory_ + "\nto " + directory);
 
         // close the old file, update the path and open the new file
         this->closeFile();
-        this->path_ = path;
-        this->bDefaultPath_ = false;
+        this->directory_ = directory;
         this->openFile();
 
         // request old output from MemoryWriter
-        MemoryWriter::getInstance().resendOutput(this);
+        if (OutputManager::getInstance().getMemoryWriter())
+            OutputManager::getInstance().getMemoryWriter()->resendOutput(this);
     }
 
Index: code/trunk/src/libraries/util/output/LogWriter.h
===================================================================
--- code/trunk/src/libraries/util/output/LogWriter.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/LogWriter.h	(revision 9550)
@@ -47,6 +47,5 @@
         @brief The LogWriter class inherits from BaseWriter and writes output to a log-file.
 
-        It is implemented as singleton because we (currently) use only one
-        log-file. The path of the file can be changed, in which case the file
+        The path of the file can be changed, in which case the file
         is rewritten by using the output stored by MemoryWriter. This adds the
         possibility to change the desired output levels before changing the
@@ -57,7 +56,16 @@
     {
         public:
-            static LogWriter& getInstance();
+            LogWriter();
+            LogWriter(const LogWriter&);
+            virtual ~LogWriter();
 
-            void setLogPath(const std::string& path);
+            void setLogDirectory(const std::string& directory);
+
+            /** @brief Returns the path to the logfile. */
+            inline std::string getPath() const
+                { return this->directory_ + '/' + this->filename_; }
+            /** @brief Returns the open file stream. */
+            inline const std::ofstream& getFile() const
+                { return this->file_; }
 
         protected:
@@ -65,15 +73,12 @@
 
         private:
-            LogWriter();
-            LogWriter(const LogWriter&);
-            virtual ~LogWriter();
-
             void openFile();
             void closeFile();
 
-            std::string filename_;  ///< The name of the log-file (without directories)
-            std::string path_;      ///< The path of the log-file (without file-name)
-            bool bDefaultPath_;     ///< If true, the log-file resides at the default path (which is usually a temporary directory)
+            void archive(int index = 0);
+            std::string getArchivedPath(int index) const;
 
+            std::string filename_;  ///< The name of the log-file (without directory)
+            std::string directory_; ///< The directory where the log-file resided (without file-name)
             std::ofstream file_;    ///< The output file stream.
     };
Index: code/trunk/src/libraries/util/output/MemoryWriter.cc
===================================================================
--- code/trunk/src/libraries/util/output/MemoryWriter.cc	(revision 9348)
+++ code/trunk/src/libraries/util/output/MemoryWriter.cc	(revision 9550)
@@ -53,13 +53,4 @@
 
     /**
-        @brief Returns the only existing instance of this singleton class.
-    */
-    /*static*/ MemoryWriter& MemoryWriter::getInstance()
-    {
-        static MemoryWriter instance;
-        return instance;
-    }
-
-    /**
         @brief Implementation of the output() function inherited from OutputListener, stores the received output in memory.
     */
Index: code/trunk/src/libraries/util/output/MemoryWriter.h
===================================================================
--- code/trunk/src/libraries/util/output/MemoryWriter.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/MemoryWriter.h	(revision 9550)
@@ -67,5 +67,7 @@
 
         public:
-            static MemoryWriter& getInstance();
+            MemoryWriter();
+            MemoryWriter(const MemoryWriter&);
+            virtual ~MemoryWriter();
 
             void resendOutput(OutputListener* listener) const;
@@ -76,8 +78,4 @@
 
         private:
-            MemoryWriter();
-            MemoryWriter(const MemoryWriter&);
-            virtual ~MemoryWriter();
-
             std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called.
     };
Index: code/trunk/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputDefinitions.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/OutputDefinitions.h	(revision 9550)
@@ -47,6 +47,11 @@
     context argument.
 */
-#define REGISTER_OUTPUT_CONTEXT(name) \
-    const OutputContextContainer& name() { static const OutputContextContainer& context = registerContext(#name); return context; }
+#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
+    #define REGISTER_OUTPUT_CONTEXT(name) \
+        const OutputContextContainer& name() { static OutputContextContainer context = registerContext(#name); return context; }
+#else
+    #define REGISTER_OUTPUT_CONTEXT(name) \
+        const OutputContextContainer& name() { return registerContext(#name); }
+#endif
 
 /**
@@ -60,6 +65,11 @@
     individually by derivatives of orxonox::SubcontextOutputListener.
 */
-#define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
-    const OutputContextContainer& subname() { static const OutputContextContainer& context = registerContext(#name, #subname); return context; }
+#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
+    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
+        const OutputContextContainer& subname() { static const OutputContextContainer context = registerContext(#name, #subname); return context; }
+#else
+    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
+        const OutputContextContainer& subname() { return registerContext(#name, #subname); }
+#endif
 
 // tolua_begin
@@ -105,4 +115,9 @@
         OutputContextSubID sub_id;  ///< The id of the sub-context (or context::no_subcontext if this container doesn't define a sub-context)
         std::string name;           ///< The name of this context
+
+        inline bool operator==(const OutputContextContainer& other) const
+        {
+            return this->mask == other.mask && this->sub_id == other.sub_id && this->name == other.name;
+        }
     };
 
Index: code/trunk/src/libraries/util/output/OutputListener.cc
===================================================================
--- code/trunk/src/libraries/util/output/OutputListener.cc	(revision 9348)
+++ code/trunk/src/libraries/util/output/OutputListener.cc	(revision 9550)
@@ -62,4 +62,27 @@
 
     /**
+        @brief Adds a listener to the list.
+    */
+    void OutputListener::registerListener(AdditionalContextListener* listener)
+    {
+        this->listeners_.push_back(listener);
+    }
+
+    /**
+        @brief Removes a listener from the list.
+    */
+    void OutputListener::unregisterListener(AdditionalContextListener* listener)
+    {
+        for (std::vector<AdditionalContextListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if (*it == listener)
+            {
+                this->listeners_.erase(it);
+                break;
+            }
+        }
+    }
+
+    /**
         @brief Defines the level mask in a way which accepts all output up to the level \c max.
     */
@@ -88,5 +111,6 @@
         this->levelMask_ = mask;
 
-        OutputManager::getInstance().updateCombinedLevelMask();
+        for (size_t i = 0; i < this->listeners_.size(); ++i)
+            this->listeners_[i]->updatedLevelMask(this);
     }
 
@@ -118,5 +142,6 @@
         this->additionalContextsLevelMask_ = mask;
 
-        OutputManager::getInstance().updateCombinedAdditionalContextsLevelMask();
+        for (size_t i = 0; i < this->listeners_.size(); ++i)
+            this->listeners_[i]->updatedAdditionalContextsLevelMask(this);
     }
 
@@ -128,5 +153,6 @@
         this->additionalContextsMask_ = mask;
 
-        OutputManager::getInstance().updateCombinedAdditionalContextsMask();
+        for (size_t i = 0; i < this->listeners_.size(); ++i)
+            this->listeners_[i]->updatedAdditionalContextsMask(this);
     }
 
Index: code/trunk/src/libraries/util/output/OutputListener.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputListener.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/OutputListener.h	(revision 9550)
@@ -55,4 +55,7 @@
             virtual ~OutputListener();
 
+            void registerListener(AdditionalContextListener* listener);
+            void unregisterListener(AdditionalContextListener* listener);
+
             void setLevelMax(OutputLevel max);
             void setLevelRange(OutputLevel min, OutputLevel max);
@@ -63,5 +66,5 @@
             void setAdditionalContextsLevelMask(OutputLevel mask);
 
-            void setAdditionalContextsMask(OutputContextMask mask);
+            virtual void setAdditionalContextsMask(OutputContextMask mask);
 
             /// @brief Returns the level mask.
@@ -78,5 +81,5 @@
 
             /// @brief Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function.
-            inline void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
+            virtual void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
                 { if (this->acceptsOutput(level, context)) this->output(level, context, lines); }
 
@@ -85,8 +88,13 @@
             virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) = 0;
 
+            inline const std::vector<AdditionalContextListener*>& getListeners() const
+                { return this->listeners_; }
+
         private:
-            OutputLevel       levelMask_;                   ///< Mask of accepted output levels, independent of contexts
-            OutputContextMask additionalContextsMask_;      ///< Mask of accepted additional contexts
-            OutputLevel       additionalContextsLevelMask_; ///< Mask of accepted output levels of the additional contexts
+            std::vector<AdditionalContextListener*> listeners_; ///< List of all registered additional context listeners
+
+            OutputLevel       levelMask_;                       ///< Mask of accepted output levels, independent of contexts
+            OutputContextMask additionalContextsMask_;          ///< Mask of accepted additional contexts
+            OutputLevel       additionalContextsLevelMask_;     ///< Mask of accepted output levels of the additional contexts
     };
 
Index: code/trunk/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/trunk/src/libraries/util/output/OutputManager.cc	(revision 9348)
+++ code/trunk/src/libraries/util/output/OutputManager.cc	(revision 9550)
@@ -33,4 +33,6 @@
 
 #include "OutputManager.h"
+
+#include <iostream>
 
 #include "MemoryWriter.h"
@@ -39,4 +41,5 @@
 #include "util/Output.h"
 #include "util/StringUtils.h"
+#include "util/SharedPtr.h"
 
 namespace orxonox
@@ -52,4 +55,12 @@
 
         this->subcontextCounter_ = 0;
+
+        this->isInitialized_ = false;
+        this->memoryWriterInstance_ = 0;
+        this->consoleWriterInstance_ = 0;
+        this->logWriterInstance_ = 0;
+
+        // register 'undefined' context in order to give it always the first context-ID
+        this->registerContext("undefined");
     }
 
@@ -59,4 +70,19 @@
     OutputManager::~OutputManager()
     {
+        while (!this->listeners_.empty())
+            this->unregisterListener(this->listeners_[0]);
+
+        if (this->memoryWriterInstance_)
+            delete this->memoryWriterInstance_;
+        if (this->consoleWriterInstance_)
+            delete this->consoleWriterInstance_;
+        if (this->logWriterInstance_)
+            delete this->logWriterInstance_;
+    }
+
+    /*static*/ SharedPtr<OutputManager>& OutputManager::Testing::getInstancePointer()
+    {
+        static SharedPtr<OutputManager> instance(new OutputManager());
+        return instance;
     }
 
@@ -66,6 +92,5 @@
     /*static*/ OutputManager& OutputManager::getInstance()
     {
-        static OutputManager instance;
-        return instance;
+        return *OutputManager::Testing::getInstancePointer();
     }
 
@@ -80,9 +105,12 @@
     /*static*/ OutputManager& OutputManager::getInstanceAndCreateListeners()
     {
-        static OutputManager& instance = OutputManager::getInstance();
-
-        static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
-        static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
-        static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
+        OutputManager& instance = *OutputManager::Testing::getInstancePointer();
+
+        if (!instance.isInitialized_) {
+            instance.isInitialized_ = true;
+            instance.memoryWriterInstance_ = new MemoryWriter();
+            instance.consoleWriterInstance_ = new ConsoleWriter(std::cout);
+            instance.logWriterInstance_ = new LogWriter();
+        }
 
         return instance;
@@ -113,4 +141,5 @@
     void OutputManager::registerListener(OutputListener* listener)
     {
+        listener->registerListener(this);
         this->listeners_.push_back(listener);
         this->updateMasks();
@@ -122,4 +151,5 @@
     void OutputManager::unregisterListener(OutputListener* listener)
     {
+        listener->unregisterListener(this);
         for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
         {
@@ -267,5 +297,5 @@
     {
         // "undefined" context is ignored because it's used implicitly if no explicit context is defined
-        static OutputContextMask undefined_mask = context::undefined().mask;
+        OutputContextMask undefined_mask = context::undefined().mask;
 
         std::string prefix = this->getLevelName(level) + ": ";
Index: code/trunk/src/libraries/util/output/OutputManager.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputManager.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/OutputManager.h	(revision 9550)
@@ -43,4 +43,5 @@
 
 #include "OutputDefinitions.h"
+#include "AdditionalContextListener.h"
 
 namespace orxonox
@@ -61,19 +62,29 @@
         Additionally OutputManager is used to register output contexts.
     */
-    class _UtilExport OutputManager
+    class _UtilExport OutputManager : public AdditionalContextListener
     {
         public:
+            OutputManager();
+            OutputManager(const OutputManager&);
+            virtual ~OutputManager();
+
             static OutputManager& getInstance();
             static OutputManager& getInstanceAndCreateListeners();
 
-            void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
+            inline MemoryWriter* getMemoryWriter()   { return this->memoryWriterInstance_; }
+            inline ConsoleWriter* getConsoleWriter() { return this->consoleWriterInstance_; }
+            inline LogWriter* getLogWriter()         { return this->logWriterInstance_; }
 
-            void registerListener(OutputListener* listener);
-            void unregisterListener(OutputListener* listener);
+            virtual void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
 
-            void updateMasks();
-            void updateCombinedLevelMask();
-            void updateCombinedAdditionalContextsLevelMask();
-            void updateCombinedAdditionalContextsMask();
+            virtual void registerListener(OutputListener* listener);
+            virtual void unregisterListener(OutputListener* listener);
+
+            virtual void updatedLevelMask(const OutputListener* listener)
+                { this->updateCombinedLevelMask(); }
+            virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener)
+                { this->updateCombinedAdditionalContextsLevelMask(); }
+            virtual void updatedAdditionalContextsMask(const OutputListener* listener)
+                { this->updateCombinedAdditionalContextsMask(); }
 
             /**
@@ -95,8 +106,16 @@
             std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
 
+            inline const std::vector<OutputListener*>& getListeners() const
+                { return this->listeners_; }
+
+            inline OutputLevel getCombinedLevelMask() const { return this->combinedLevelMask_; }
+            inline OutputLevel getCombinedAdditionalContextsLevelMask() const { return this->combinedAdditionalContextsLevelMask_; }
+            inline OutputContextMask getCombinedAdditionalContextsMask() const { return this->combinedAdditionalContextsMask_; }
+
         private:
-            OutputManager();
-            OutputManager(const OutputManager&);
-            ~OutputManager();
+            void updateMasks();
+            void updateCombinedLevelMask();
+            void updateCombinedAdditionalContextsLevelMask();
+            void updateCombinedAdditionalContextsMask();
 
             std::vector<OutputListener*> listeners_;                            ///< List of all registered output listeners
@@ -109,4 +128,15 @@
             std::map<std::string, OutputContextContainer> contextContainers_;   ///< Contains all contexts including sub-contexts and their containers
             OutputContextSubID subcontextCounter_;                              ///< Counts the number of sub-contexts (and generates their IDs)
+
+            bool isInitialized_;                                                ///< Becomes true once the following instances were created
+            MemoryWriter*  memoryWriterInstance_;                               ///< The main instance of MemoryWriter, managed by OutputManager
+            ConsoleWriter* consoleWriterInstance_;                              ///< The main instance of ConsoleWriter, managed by OutputManager
+            LogWriter*     logWriterInstance_;                                  ///< The main instance of LogWriter, managed by OutputManager
+
+        public:
+            struct _UtilExport Testing
+            {
+                static SharedPtr<OutputManager>& getInstancePointer();
+            };
     };
 }
Index: code/trunk/src/libraries/util/output/OutputStream.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputStream.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/OutputStream.h	(revision 9550)
@@ -102,4 +102,8 @@
             }
 
+            inline const OutputLevel getOutputLevel() const { return this->level_; }
+            inline const OutputContextContainer* getOutputContext() const { return this->context_; }
+            inline bool acceptsOutput() const { return this->bAcceptsOutput_; }
+
         private:
             /// @brief Generic function to add values to the output stream, using the inherited << operator from std::ostringstream.
Index: code/trunk/src/libraries/util/output/SubcontextOutputListener.h
===================================================================
--- code/trunk/src/libraries/util/output/SubcontextOutputListener.h	(revision 9348)
+++ code/trunk/src/libraries/util/output/SubcontextOutputListener.h	(revision 9550)
@@ -73,8 +73,11 @@
             virtual ~SubcontextOutputListener();
 
-            void setAdditionalContextsMask(OutputContextMask mask);
+            virtual void setAdditionalContextsMask(OutputContextMask mask);
             void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
 
             virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
+
+            inline const std::set<OutputContextSubID>& getSubcontexts() const
+                { return this->subcontexts_; }
 
         private:
