Changeset 2710 for code/trunk/src/util/OutputHandler.cc
- Timestamp:
- Feb 28, 2009, 7:46:37 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore deleted
- Property svn:mergeinfo changed
-
code/trunk/src/util
- Property svn:mergeinfo changed
-
code/trunk/src/util/OutputHandler.cc
r2662 r2710 33 33 34 34 #include "OutputHandler.h" 35 #include <time.h> 35 36 #include <ctime> 37 #include <cstdlib> 36 38 37 39 namespace orxonox … … 41 43 @param logfilename The name of the logfile 42 44 */ 43 OutputHandler::OutputHandler(const std::string& logfilename) 44 { 45 OutputHandler::OutputHandler() 46 { 47 #ifdef ORXONOX_PLATFORM_WINDOWS 48 char* pTempDir = getenv("TEMP"); 49 this->logfilename_ = std::string(pTempDir) + "/orxonox.log"; 50 #else 51 this->logfilename_ = "/tmp/orxonox.log"; 52 #endif 53 #ifdef NDEBUG 54 this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 2; 55 this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 1; 56 #else 57 this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 3; 58 this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 2; 59 #endif 60 45 61 this->outputBuffer_ = &this->fallbackBuffer_; 46 this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2;47 this->logfilename_ = logfilename;48 62 this->logfile_.open(this->logfilename_.c_str(), std::fstream::out); 49 63 … … 53 67 timeinfo = localtime(&rawtime); 54 68 55 this->logfile_ << "Started log at" << asctime(timeinfo) << std::endl;69 this->logfile_ << "Started log on " << asctime(timeinfo) << std::endl; 56 70 this->logfile_.flush(); 57 71 } … … 72 86 OutputHandler& OutputHandler::getOutStream() 73 87 { 74 static OutputHandler orxout ("orxonox.log");88 static OutputHandler orxout; 75 89 return orxout; 76 90 } … … 112 126 113 127 /** 128 @brief Sets the path where to create orxonox.log 129 @param Path string with trailing slash 130 */ 131 void OutputHandler::setLogPath(const std::string& path) 132 { 133 OutputHandler::getOutStream().logfile_.close(); 134 // store old content 135 std::ifstream old; 136 old.open(OutputHandler::getOutStream().logfilename_.c_str()); 137 OutputHandler::getOutStream().logfilename_ = path + "orxonox.log"; 138 OutputHandler::getOutStream().logfile_.open(OutputHandler::getOutStream().logfilename_.c_str(), std::fstream::out); 139 OutputHandler::getOutStream().logfile_ << old.rdbuf(); 140 old.close(); 141 OutputHandler::getOutStream().logfile_.flush(); 142 } 143 144 /** 114 145 @brief Overloaded << operator, redirects the output to the console and the logfile. 115 146 @param sb The streambuffer that should be shown in the console
Note: See TracChangeset
for help on using the changeset viewer.