- Timestamp:
- May 20, 2011, 3:53:21 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/unity_build/src/libraries/util/OutputHandler.cc
r7401 r8515 147 147 OutputListener that writes all the output piece by piece to an array 148 148 associated with the corresponding output level. 149 Used as buffer until all output devices have been initialised. 149 150 @note 150 Only output below or equal to the current soft debug level is written151 to minimise huge arrays for the normal run.151 At some point, OutputHandler::disableMemoryLog() has to be called in 152 order to avoid large memory footprints of this class. 152 153 */ 153 154 class MemoryLogWriter : public OutputListener … … 156 157 friend class OutputHandler; 157 158 158 /**159 @brief160 Sets the right soft debug level and registers itself161 */162 159 MemoryLogWriter() 163 160 : OutputListener("memoryLog") … … 166 163 } 167 164 168 //! Push edthe just written output to the internal array165 //! Push the just written output to the internal array 169 166 void outputChanged(int level) 170 167 { … … 180 177 181 178 private: 182 std::ostringstream 183 std::vector<std::pair<int, std::string> >output_; //!< Vector containing ALL output179 std::ostringstream buffer_; //!< Stream object used to process the output 180 OutputHandler::OutputVector output_; //!< Vector containing ALL output 184 181 }; 185 182 … … 212 209 this->registerOutputListener(this->consoleWriter_); 213 210 214 this-> output_ = new MemoryLogWriter();215 // W e capture as much input as the listener with the highest level216 this-> output_->softDebugLevel_ = getSoftDebugLevel();217 this->registerOutputListener(this-> output_);211 this->memoryBuffer_ = new MemoryLogWriter(); 212 // Write everything, e.g. use hardDebugLevel 213 this->memoryBuffer_->softDebugLevel_ = hardDebugLevel; 214 this->registerOutputListener(this->memoryBuffer_); 218 215 } 219 216 … … 223 220 delete this->logFile_; 224 221 delete this->consoleWriter_; 225 delete this-> output_;222 delete this->memoryBuffer_; // Might already be NULL 226 223 } 227 224 … … 267 264 } 268 265 269 OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorBegin() const 270 { 271 return this->output_->output_.begin(); 272 } 273 274 OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorEnd() const 275 { 276 return this->output_->output_.end(); 266 void OutputHandler::disableMemoryLog() 267 { 268 this->unregisterOutputListener(this->memoryBuffer_); 269 // Only clear the buffer so we can still reference the vector 270 this->memoryBuffer_->output_.clear(); 271 } 272 273 const OutputHandler::OutputVector& OutputHandler::getOutput() const 274 { 275 return this->memoryBuffer_->output_; 277 276 } 278 277
Note: See TracChangeset
for help on using the changeset viewer.