Changeset 8799 for code/branches/output/src/libraries/util
- Timestamp:
- Jul 30, 2011, 7:51:08 PM (13 years ago)
- Location:
- code/branches/output/src/libraries/util/output
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/util/output/BaseWriter.cc
r8795 r8799 33 33 namespace orxonox 34 34 { 35 BaseWriter::BaseWriter( )35 BaseWriter::BaseWriter(const std::string& name) 36 36 { 37 this->name_ = name; 38 39 this->configurableMaxLevel_ = level::none; 40 this->configurableContextsMaxLevel_ = level::verbose; 37 41 } 38 42 … … 43 47 void BaseWriter::output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines) 44 48 { 45 const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context); 46 std::string blanks(prefix.length(), ' '); 49 if (level <= this->configurableMaxLevel_ || (level <= this->configurableContextsMaxLevel_ && this->isAdditionalContext(context))) 50 { 51 const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context); 52 std::string blanks(prefix.length(), ' '); 47 53 48 for (size_t i = 0; i < lines.size(); ++i) 49 this->printLine((i == 0 ? prefix : blanks) + lines[i], level); 54 for (size_t i = 0; i < lines.size(); ++i) 55 this->printLine((i == 0 ? prefix : blanks) + lines[i], level); 56 } 57 } 58 59 void BaseWriter::setLevelMax(OutputLevel max) 60 { 61 this->configurableMaxLevel_ = max; 62 this->changedConfigurableLevels(); 63 } 64 65 void BaseWriter::changedConfigurableLevels() 66 { 67 OutputLevel max_level = std::max(this->configurableMaxLevel_, this->configurableContextsMaxLevel_); 68 OutputListener::setLevelMax(max_level); 69 } 70 71 void BaseWriter::changedConfigurableContexts() 72 { 73 this->configurableContextsSet_.clear(); 74 for (size_t i = 0; i < this->configurableContexts_.size(); ++i) 75 this->configurableContextsSet_.insert(this->configurableContexts_[i]); 76 } 77 78 bool BaseWriter::isAdditionalContext(OutputContext context) const 79 { 80 const std::string& name = OutputManager::getInstance().getContextName(context); 81 std::set<std::string>::const_iterator it = this->configurableContextsSet_.find(name); 82 return (it != this->configurableContextsSet_.end()); 50 83 } 51 84 } -
code/branches/output/src/libraries/util/output/BaseWriter.h
r8795 r8799 31 31 32 32 #include "util/UtilPrereqs.h" 33 34 #include <set> 35 #include <vector> 36 33 37 #include "OutputListener.h" 34 38 … … 38 42 { 39 43 public: 40 BaseWriter( );44 BaseWriter(const std::string& name); 41 45 virtual ~BaseWriter(); 46 47 const std::string& getName() const 48 { return this->name_; } 49 50 void setLevelMax(OutputLevel max); 51 52 OutputLevel configurableMaxLevel_; 53 inline std::string getConfigurableMaxLevelName() const 54 { return "outputLevel" + this->name_; } 55 56 OutputLevel configurableContextsMaxLevel_; 57 inline std::string getConfigurableContextsMaxLevelName() const 58 { return "outputContextsLevel" + this->name_; } 59 60 std::vector<std::string> configurableContexts_; 61 inline std::string getConfigurableContextsName() const 62 { return "outputContexts" + this->name_; } 63 64 void changedConfigurableLevels(); 65 void changedConfigurableContexts(); 66 67 static inline std::string getConfigurableSectionName() 68 { return "Output"; } 42 69 43 70 protected: … … 46 73 private: 47 74 virtual void printLine(const std::string& line, OutputLevel level) = 0; 75 76 void setLevelRange(OutputLevel min, OutputLevel max); 77 void setLevelMask(OutputLevel mask); 78 79 bool isAdditionalContext(OutputContext context) const; 80 81 std::string name_; 82 std::set<std::string> configurableContextsSet_; 48 83 }; 49 84 } -
code/branches/output/src/libraries/util/output/ConsoleWriter.cc
r8795 r8799 35 35 namespace orxonox 36 36 { 37 ConsoleWriter::ConsoleWriter() 37 ConsoleWriter::ConsoleWriter() : BaseWriter("Console") 38 38 { 39 39 #ifdef ORXONOX_RELEASE -
code/branches/output/src/libraries/util/output/LogWriter.cc
r8795 r8799 36 36 namespace orxonox 37 37 { 38 LogWriter::LogWriter() 38 LogWriter::LogWriter() : BaseWriter("Log") 39 39 { 40 40 this->setLevelMax(level::internal_info); 41 41 42 this->filename_ = "orxonox 2.log";42 this->filename_ = "orxonox.log"; 43 43 44 44 // Get path for a temporary file -
code/branches/output/src/libraries/util/output/OutputDefinitions.h
r8798 r8799 44 44 static const OutputLevel all = 0xFFFF; 45 45 static const OutputLevel none = 0x0000; 46 46 47 static const OutputLevel debug_output = 0x0001; 47 48 static const OutputLevel user_error = 0x0002; -
code/branches/output/src/libraries/util/output/OutputManager.cc
r8787 r8799 166 166 } 167 167 168 OutputContext OutputManager::getContextValue(const std::string& name) const 169 { 170 boost::bimap<OutputContext, std::string>::right_map::const_iterator it = this->contexts_.right.find(name); 171 if (it != this->contexts_.right.end()) 172 return it->second; 173 else 174 return context::none; 175 } 176 168 177 std::string OutputManager::getComposedContextName(OutputContext context) const 169 178 { -
code/branches/output/src/libraries/util/output/OutputManager.h
r8787 r8799 66 66 const std::string& getLevelName(OutputLevel level) const; 67 67 const std::string& getContextName(OutputContext context) const; 68 OutputContext getContextValue(const std::string& name) const; 69 68 70 std::string getComposedContextName(OutputContext context) const; 69 71 std::string getDefaultPrefix(OutputLevel level, OutputContext context) const;
Note: See TracChangeset
for help on using the changeset viewer.