- Timestamp:
- Aug 11, 2011, 11:20:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/util/output/BaseWriter.cc
r8831 r8833 38 38 39 39 this->configurableMaxLevel_ = level::none; 40 this->configurableContextsMaxLevel_ = level::verbose; 41 this->configurableContexts_.push_back("example"); 42 this->changedConfigurableLevels(); 40 this->configurableAdditionalContextsMaxLevel_ = level::verbose; 41 this->configurableAdditionalContexts_.push_back("example"); 42 43 this->subcontextsCheckMask_ = context::none; 44 45 this->changedConfigurableLevel(); 46 this->changedConfigurableAdditionalContextsLevel(); 47 this->changedConfigurableAdditionalContexts(); 43 48 } 44 49 … … 47 52 } 48 53 49 void BaseWriter::output(OutputLevel level, OutputContextcontext, const std::vector<std::string>& lines)54 void BaseWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) 50 55 { 51 if ( level <= this->configurableMaxLevel_ || (level <= this->configurableContextsMaxLevel_ && this->isAdditionalContext(context)))56 if (((this->subcontextsCheckMask_ & context.mask) == 0) || (this->subcontexts_.find(context.sub_id) != this->subcontexts_.end())) 52 57 { 53 58 const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context); … … 62 67 { 63 68 this->configurableMaxLevel_ = max; 64 this->changedConfigurableLevel s();69 this->changedConfigurableLevel(); 65 70 } 66 71 67 void BaseWriter:: changedConfigurableLevels()72 void BaseWriter::setAdditionalContextsLevelMax(OutputLevel max) 68 73 { 69 int max_level = std::max(this->configurableMaxLevel_, this->configurableContextsMaxLevel_);70 OutputListener::setLevelMax(static_cast<OutputLevel>(max_level));74 this->configurableAdditionalContextsMaxLevel_ = max; 75 this->changedConfigurableAdditionalContextsLevel(); 71 76 } 72 77 73 void BaseWriter::changedConfigurable Contexts()78 void BaseWriter::changedConfigurableLevel() 74 79 { 75 this->configurableContextsSet_.clear(); 76 for (size_t i = 0; i < this->configurableContexts_.size(); ++i) 77 this->configurableContextsSet_.insert(this->configurableContexts_[i]); 80 OutputListener::setLevelMax(static_cast<OutputLevel>(this->configurableMaxLevel_)); 78 81 } 79 82 80 bool BaseWriter::isAdditionalContext(OutputContext context) const83 void BaseWriter::changedConfigurableAdditionalContextsLevel() 81 84 { 82 const std::string& name = OutputManager::getInstance().getContextName(context); 83 std::set<std::string>::const_iterator it = this->configurableContextsSet_.find(name); 84 return (it != this->configurableContextsSet_.end()); 85 OutputListener::setAdditionalContextsLevelMax(static_cast<OutputLevel>(this->configurableAdditionalContextsMaxLevel_)); 86 } 87 88 void BaseWriter::changedConfigurableAdditionalContexts() 89 { 90 OutputContextMask context_mask = context::none; 91 this->subcontextsCheckMask_ = context::none; 92 93 this->subcontexts_.clear(); 94 this->subcontexts_.insert(context::no_subcontext); 95 96 for (size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i) 97 { 98 const std::string& full_name = this->configurableAdditionalContexts_[i]; 99 100 std::string name = full_name; 101 std::string subname; 102 103 size_t pos = full_name.find("::"); 104 if (pos != std::string::npos) 105 { 106 name = full_name.substr(0, pos); 107 subname = full_name.substr(pos + 2); 108 } 109 110 const OutputContextContainer& container = OutputManager::getInstance().registerContext(name, subname); 111 112 context_mask |= container.mask; 113 114 if (container.sub_id != context::no_subcontext) 115 { 116 this->subcontexts_.insert(container.sub_id); 117 this->subcontextsCheckMask_ |= container.mask; 118 } 119 } 120 121 this->setAdditionalContextsMask(context_mask); 85 122 } 86 123 }
Note: See TracChangeset
for help on using the changeset viewer.