Changeset 8729 for code/trunk/src/libraries/util/OutputHandler.h
- Timestamp:
- Jul 4, 2011, 2:47:44 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/libraries/util/OutputHandler.h
r7401 r8729 39 39 #include "UtilPrereqs.h" 40 40 41 #include <list>42 41 #include <ostream> 43 42 #include <string> … … 63 62 enum Value 64 63 { 64 TDebug = -1, 65 65 None = 0, 66 66 Error = 1, … … 103 103 { return OutputHandler::getInstance().setOutputLevel(level); } 104 104 105 typedef std::vector<std::pair<int, std::string> >::const_iterator OutputVectorIterator; 106 //! Returns an iterator to the beginning of the all-output vector 107 OutputVectorIterator getOutputVectorBegin() const; 108 //! Returns an iterator to the end of the all-output vector 109 OutputVectorIterator getOutputVectorEnd() const; 105 typedef std::vector<std::pair<int, std::string> > OutputVector; 106 //! Returns all output written so far (empty if disableMemoryLog() was called) 107 const OutputVector& getOutput() const; 110 108 111 109 //! Writes to all output devices … … 136 134 //! Set the log path once the program has been properly initialised 137 135 void setLogPath(const std::string& path); 136 /** Rewrites the log file (completely respects the current debug level). 137 Once disableMemoryLog() has been called, this function will do nothing. 138 */ 139 void rewriteLogFile(); 140 138 141 //! Disables the std::cout stream for output 139 142 void disableCout(); 140 143 //! Enables the std::cout stream for output (startup behaviour) 141 144 void enableCout(); 145 //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage) 146 void disableMemoryLog(); 142 147 143 148 //! Sets the level of the incoming output and returns the OutputHandler … … 213 218 inline operator int() const { return 0; } 214 219 215 //! Name of the OutputListener that writes to the log file216 static const std::string logFileOutputListenerName_s;217 218 220 private: 219 221 OutputHandler(); … … 221 223 OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined 222 224 223 std::list<OutputListener*> listeners_; //!< Array with all registered output listeners 224 int outputLevel_; //!< The level of the incoming output 225 LogFileWriter* logFile_; //!< Listener that writes to the log file 226 ConsoleWriter* consoleWriter_; //!< Listener for std::cout (just program beginning) 227 MemoryLogWriter* output_; //!< Listener that Stores ALL output below the current soft debug level 228 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 225 /// Evaluates the maximum global log level 226 void updateGlobalDebugLevel(); 227 228 std::vector<OutputListener*> listeners_; //!< Array with all registered output listeners 229 int outputLevel_; //!< The level of the incoming output 230 LogFileWriter* logFile_; //!< Writes output to the log file 231 ConsoleWriter* consoleWriter_; //!< Writes to std::cout (can be disabled) 232 MemoryLogWriter* memoryBuffer_; //!< Writes to memory as a buffer (can/must be stopped at some time) 233 static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access 229 234 }; 230 235 … … 251 256 //! Returns the name of this output listener 252 257 const std::string& getOutputListenerName() const { return this->name_; } 253 //! Returns the soft debug level of the listener254 int getSoftDebugLevel() const { return this->softDebugLevel_; }255 //! Sets the soft debug level of the listener256 void setSoftDebugLevel(int level)257 {258 this->softDebugLevel_ = level;259 OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);260 }261 258 262 259 protected: … … 271 268 inline OutputHandler& OutputHandler::output(const T& output) 272 269 { 273 for (std:: list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)270 for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 274 271 { 275 272 if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
Note: See TracChangeset
for help on using the changeset viewer.