Changeset 9538 for code/branches/testing/src/libraries
- Timestamp:
- Mar 8, 2013, 11:16:56 PM (12 years ago)
- Location:
- code/branches/testing/src/libraries
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/testing/src/libraries/core/Core.cc
r9536 r9538 181 181 182 182 // Set the correct log path and rewrite the log file with the correct log levels 183 OutputManager::getInstance().getLogWriter().setLog Path(PathConfig::getLogPathString());183 OutputManager::getInstance().getLogWriter().setLogDirectory(PathConfig::getLogPathString()); 184 184 185 185 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN) -
code/branches/testing/src/libraries/util/output/LogWriter.cc
r9536 r9538 58 58 // get the path for a temporary file, depending on the system 59 59 #ifdef ORXONOX_PLATFORM_WINDOWS 60 this-> path_ = getenv("TEMP");60 this->directory_ = getenv("TEMP"); 61 61 #else 62 this-> path_ = "/tmp";62 this->directory_ = "/tmp"; 63 63 #endif 64 this->bDefaultPath_ = true; 64 65 // send a message to the user so that he can find the file in the case of a crash. 66 OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + this->getPath()); 65 67 66 68 this->openFile(); … … 80 82 void LogWriter::openFile() 81 83 { 82 // get the full file-name83 std::string name = this->path_ + '/' + this->filename_;84 85 // if we open the log file in the default directory, send a message to the user so that he can find the file in the case of a crash.86 if (this->bDefaultPath_)87 OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + name);88 89 84 // open the file 90 this->file_.open( name.c_str(), std::fstream::out);85 this->file_.open(this->getPath().c_str(), std::fstream::out); 91 86 92 87 // check if it worked and print some output … … 112 107 @brief Changes the path of the log-file. Re-writes the log-file by using MemoryWriter. 113 108 */ 114 void LogWriter::setLog Path(const std::string& path)109 void LogWriter::setLogDirectory(const std::string& directory) 115 110 { 116 111 // notify about the change of the log-file (because the old file will no longer be updated) 117 OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this-> path_ + "\nto " + path);112 OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->directory_ + "\nto " + directory); 118 113 119 114 // close the old file, update the path and open the new file 120 115 this->closeFile(); 121 this->path_ = path; 122 this->bDefaultPath_ = false; 116 this->directory_ = directory; 123 117 this->openFile(); 124 118 -
code/branches/testing/src/libraries/util/output/LogWriter.h
r9536 r9538 61 61 virtual ~LogWriter(); 62 62 63 void setLogPath(const std::string& path); 63 void setLogDirectory(const std::string& directory); 64 65 /** @brief Returns the path to the logfile. */ 66 inline std::string getPath() const 67 { return this->directory_ + '/' + this->filename_; } 68 /** @brief Returns the open file stream. */ 69 inline const std::ofstream& getFile() const 70 { return this->file_; } 64 71 65 72 protected: … … 70 77 void closeFile(); 71 78 72 std::string filename_; ///< The name of the log-file (without directories) 73 std::string path_; ///< The path of the log-file (without file-name) 74 bool bDefaultPath_; ///< If true, the log-file resides at the default path (which is usually a temporary directory) 75 79 std::string filename_; ///< The name of the log-file (without directory) 80 std::string directory_; ///< The directory where the log-file resided (without file-name) 76 81 std::ofstream file_; ///< The output file stream. 77 82 };
Note: See TracChangeset
for help on using the changeset viewer.