Added --stdout= command line option to change the name of

the stdout.log file.
This commit is contained in:
hiker 2015-10-22 11:51:18 +11:00
parent 65454db0ce
commit 4833659085
3 changed files with 17 additions and 3 deletions

View File

@ -64,6 +64,7 @@ namespace irr {
std::vector<std::string> FileManager::m_root_dirs;
std::string FileManager::m_stdout_filename = "stdout.log";
#ifdef __APPLE__
// dynamic data path detection onmac
@ -1044,6 +1045,15 @@ std::string FileManager::checkAndCreateLinuxDir(const char *env_name,
} // checkAndCreateLinuxDir
#endif
//-----------------------------------------------------------------------------
/** Sets the name for the stdout log file.
* \param filename Filename to use (relative to the user config dir).
*/
void FileManager::setStdoutName(const std::string& filename)
{
m_stdout_filename = filename;
} // setStdoutName
//-----------------------------------------------------------------------------
/** Redirects output to go into files in the user's config directory
* instead of to the console. It keeps backup copies of previous stdout files
@ -1053,7 +1063,7 @@ void FileManager::redirectOutput()
{
// Do a simple log rotate: stdout.log.2 becomes stdout.log.3 etc
const int NUM_BACKUPS=3;
std::string logoutfile = getUserConfigFile("stdout.log");
std::string logoutfile = getUserConfigFile(m_stdout_filename);
for(int i=NUM_BACKUPS; i>1; i--)
{
std::ostringstream out_old;

View File

@ -69,6 +69,9 @@ private:
/** The list of all root directories. */
static std::vector<std::string> m_root_dirs;
/** Name of stdout file. */
static std::string m_stdout_filename;
/** Directory to store screenshots in. */
std::string m_screenshot_dir;
@ -109,6 +112,7 @@ public:
~FileManager();
void init();
static void addRootDirs(const std::string &roots);
static void setStdoutName(const std::string &name);
io::IXMLReader *createXMLReader(const std::string &filename);
XMLNode *createXMLTree(const std::string &filename);
XMLNode *createXMLTreeFromString(const std::string & content);

View File

@ -1265,9 +1265,9 @@ int main(int argc, char *argv[] )
handleCmdLineOutputModifier();
if(CommandLine::has("--root", &s))
{
FileManager::addRootDirs(s);
}
if (CommandLine::has("--stdout", &s))
FileManager::setStdoutName(s);
// Init the minimum managers so that user config exists, then
// handle all command line options that do not need (or must