Changeset 699 for code/branches/FICN/src/orxonox/core/OutputHandler.h
- Timestamp:
- Dec 27, 2007, 4:58:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/OutputHandler.h
r685 r699 49 49 { 50 50 public: 51 enum OutputDevice 52 { 53 LD_All, 54 LD_Console, 55 LD_Logfile, 56 LD_Shell 57 }; 58 51 59 static OutputHandler& getOutStream(); 52 60 53 61 /** @returns a reference to the logfile. */ 54 inline std::ofstream& getLogfile() { return this->logfile_; } 62 inline std::ofstream& getLogfile() 63 { return this->logfile_; } 64 65 /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */ 66 inline OutputHandler& setOutputLevel(int level) 67 { this->outputLevel_ = level; return *this; } 68 69 /** @returns the level of the incoming output. */ 70 inline int getOutputLevel() const 71 { return this->outputLevel_; } 72 73 static int getSoftDebugLevel(OutputHandler::OutputDevice device); 55 74 56 75 template <class T> … … 94 113 std::ofstream logfile_; //!< The logfile where the output is logged 95 114 std::string logfilename_; //!< The name of the logfile 115 int outputLevel_; //!< The level of the incoming output 96 116 }; 97 117 … … 104 124 OutputHandler& OutputHandler::output(const T& output) 105 125 { 106 std::cout << output; 107 this->logfile_ << output; 108 this->logfile_.flush(); 126 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_) 127 std::cout << output; 128 129 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_) 130 { 131 this->logfile_ << output; 132 this->logfile_.flush(); 133 } 134 109 135 return *this; 110 136 } 111 /*112 _CoreExport OutputHandler& operator<<(OutputHandler& out, char c);113 _CoreExport OutputHandler& operator<<(OutputHandler& out, signed char c);114 _CoreExport OutputHandler& operator<<(OutputHandler& out, unsigned char c);115 137 116 _CoreExport OutputHandler& operator<<(OutputHandler& out, const char* s);117 _CoreExport OutputHandler& operator<<(OutputHandler& out, const signed char* s);118 _CoreExport OutputHandler& operator<<(OutputHandler& out, const unsigned char* s);119 */120 138 /** 121 139 @brief Overloading of the non-member << operator to redirect the output of classes with self defined '<< to std::ostream' operators to the console and the logfile. … … 127 145 OutputHandler& operator<<(OutputHandler& out, const T& output) 128 146 { 129 std::cout << output; 130 out.getLogfile() << output; 131 out.getLogfile().flush(); 147 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= out.getOutputLevel()) 148 std::cout << output; 149 150 if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= out.getOutputLevel()) 151 { 152 out.getLogfile() << output; 153 out.getLogfile().flush(); 154 } 155 132 156 return out; 133 157 }
Note: See TracChangeset
for help on using the changeset viewer.