Changeset 8774
- Timestamp:
- Jul 24, 2011, 11:50:20 PM (13 years ago)
- 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 43 43 output/OutputManager.cc 44 44 output/OutputListener.cc 45 output/LogWriter.cc 46 output/MemoryWriter.cc 45 47 ) 46 48 -
code/branches/output/src/libraries/util/output/OutputDefinitions.h
r8771 r8774 69 69 static const OutputContext test1 = registerContext("test1"); 70 70 static const OutputContext test2 = registerContext("test2"); 71 static const OutputContext output = registerContext("output"); 71 72 } 72 73 } -
code/branches/output/src/libraries/util/output/OutputListener.h
r8772 r8774 42 42 class _UtilExport OutputListener 43 43 { 44 friend class OutputManager;45 46 44 public: 47 45 OutputListener(); … … 63 61 { return ((this->levelMask_ & level) && (this->contextMask_ & context)); } 64 62 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: 65 67 virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines) = 0; 66 68 -
code/branches/output/src/libraries/util/output/OutputManager.cc
r8772 r8774 31 31 #include "util/Debug.h" 32 32 #include "OutputListener.h" 33 #include "MemoryWriter.h" 34 #include "LogWriter.h" 33 35 34 36 namespace orxonox … … 44 46 } 45 47 48 protected: 46 49 virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines) 47 50 { 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); 56 52 std::string blanks(prefix.length(), ' '); 57 53 … … 74 70 { 75 71 static OutputManager& instance = OutputManager::getInstanceInternal(); 72 76 73 static ConsoleOutput consoleOutputInstance; 74 static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance; 75 static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance; 76 77 77 return instance; 78 78 } … … 94 94 95 95 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); 98 97 } 99 98 … … 211 210 return name; 212 211 } 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 } 213 225 } 214 226 } -
code/branches/output/src/libraries/util/output/OutputManager.h
r8772 r8774 46 46 class _UtilExport OutputManager 47 47 { 48 friend class OutputListener;49 50 48 public: 51 49 static OutputManager& getInstance(); 50 static OutputManager& getInstanceInternal(); 52 51 53 52 void pushMessage(OutputLevel level, OutputContext context, const std::string& message); … … 73 72 const std::string& getContextName(OutputContext context) const; 74 73 std::string getComposedContextName(OutputContext context) const; 74 std::string getDefaultPrefix(OutputLevel level, OutputContext context) const; 75 75 76 76 private: … … 78 78 OutputManager(const OutputManager&); 79 79 ~OutputManager(); 80 81 static OutputManager& getInstanceInternal();82 80 83 81 std::vector<OutputListener*> listeners_;
Note: See TracChangeset
for help on using the changeset viewer.