Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8774 for code


Ignore:
Timestamp:
Jul 24, 2011, 11:50:20 PM (13 years ago)
Author:
landauf
Message:

added LogWriter and MemoryWriter

Location:
code/branches/output/src/libraries/util
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/util/CMakeLists.txt

    r8765 r8774  
    4343  output/OutputManager.cc
    4444  output/OutputListener.cc
     45  output/LogWriter.cc
     46  output/MemoryWriter.cc
    4547)
    4648
  • code/branches/output/src/libraries/util/output/OutputDefinitions.h

    r8771 r8774  
    6969        static const OutputContext test1     = registerContext("test1");
    7070        static const OutputContext test2     = registerContext("test2");
     71        static const OutputContext output    = registerContext("output");
    7172    }
    7273}
  • code/branches/output/src/libraries/util/output/OutputListener.h

    r8772 r8774  
    4242    class _UtilExport OutputListener
    4343    {
    44         friend class OutputManager;
    45 
    4644        public:
    4745            OutputListener();
     
    6361                { return ((this->levelMask_ & level) && (this->contextMask_ & context)); }
    6462
     63            inline void unfilteredOutput(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
     64                { if (this->acceptsOutput(level, context)) this->output(level, context, lines); }
     65
     66        protected:
    6567            virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines) = 0;
    6668
  • code/branches/output/src/libraries/util/output/OutputManager.cc

    r8772 r8774  
    3131#include "util/Debug.h"
    3232#include "OutputListener.h"
     33#include "MemoryWriter.h"
     34#include "LogWriter.h"
    3335
    3436namespace orxonox
     
    4446            }
    4547
     48        protected:
    4649            virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
    4750            {
    48                 std::string prefix = OutputManager::getInstance().getLevelName(level) + ": ";
    49                 if (context != context::undefined)
    50                 {
    51                     std::string context_name = OutputManager::getInstance().getContextName(context);
    52                     if (context_name == "")
    53                         context_name = OutputManager::getInstance().getComposedContextName(context);
    54                     prefix += "[" + context_name + "] ";
    55                 }
     51                const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
    5652                std::string blanks(prefix.length(), ' ');
    5753
     
    7470    {
    7571        static OutputManager& instance = OutputManager::getInstanceInternal();
     72
    7673        static ConsoleOutput consoleOutputInstance;
     74        static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
     75        static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
     76
    7777        return instance;
    7878    }
     
    9494
    9595        for (size_t i = 0; i < this->listeners_.size(); ++i)
    96             if (this->listeners_[i]->acceptsOutput(level, context))
    97                 this->listeners_[i]->output(level, context, lines);
     96            this->listeners_[i]->unfilteredOutput(level, context, lines);
    9897    }
    9998
     
    211210        return name;
    212211    }
     212
     213    std::string OutputManager::getDefaultPrefix(OutputLevel level, OutputContext context) const
     214    {
     215        std::string prefix = this->getLevelName(level) + ": ";
     216        if (context != context::undefined)
     217        {
     218            std::string context_name = this->getContextName(context);
     219            if (context_name == "")
     220                context_name = this->getComposedContextName(context);
     221            prefix += "[" + context_name + "] ";
     222        }
     223        return prefix;
     224    }
    213225}
    214226}
  • code/branches/output/src/libraries/util/output/OutputManager.h

    r8772 r8774  
    4646    class _UtilExport OutputManager
    4747    {
    48         friend class OutputListener;
    49 
    5048        public:
    5149            static OutputManager& getInstance();
     50            static OutputManager& getInstanceInternal();
    5251
    5352            void pushMessage(OutputLevel level, OutputContext context, const std::string& message);
     
    7372            const std::string& getContextName(OutputContext context) const;
    7473            std::string getComposedContextName(OutputContext context) const;
     74            std::string getDefaultPrefix(OutputLevel level, OutputContext context) const;
    7575
    7676        private:
     
    7878            OutputManager(const OutputManager&);
    7979            ~OutputManager();
    80 
    81             static OutputManager& getInstanceInternal();
    8280
    8381            std::vector<OutputListener*> listeners_;
Note: See TracChangeset for help on using the changeset viewer.