Przeglądaj źródła

add dedicated method to get logs path

Andrey Filipenkov 3 lat temu
rodzic
commit
99af5bbe4c

+ 1 - 1
client/CMT.cpp

@@ -232,7 +232,7 @@ int main(int argc, char * argv[])
 	*console->cb = processCommand;
 	*console->cb = processCommand;
 	console->start();
 	console->start();
 
 
-	const bfs::path logPath = VCMIDirs::get().userCachePath() / "VCMI_Client_log.txt";
+	const bfs::path logPath = VCMIDirs::get().userLogsPath() / "VCMI_Client_log.txt";
 	logConfig = new CBasicLogConfigurator(logPath, console);
 	logConfig = new CBasicLogConfigurator(logPath, console);
 	logConfig->configureDefault();
 	logConfig->configureDefault();
 	logGlobal->info(NAME);
 	logGlobal->info(NAME);

+ 1 - 1
client/CServerHandler.cpp

@@ -685,7 +685,7 @@ void CServerHandler::threadRunServer()
 {
 {
 #ifndef VCMI_ANDROID
 #ifndef VCMI_ANDROID
 	setThreadName("CServerHandler::threadRunServer");
 	setThreadName("CServerHandler::threadRunServer");
-	const std::string logName = (VCMIDirs::get().userCachePath() / "server_log.txt").string();
+	const std::string logName = (VCMIDirs::get().userLogsPath() / "server_log.txt").string();
 	std::string comm = VCMIDirs::get().serverPath().string()
 	std::string comm = VCMIDirs::get().serverPath().string()
 		+ " --port=" + getDefaultPortStr()
 		+ " --port=" + getDefaultPortStr()
 		+ " --run-by-client"
 		+ " --run-by-client"

+ 1 - 1
launcher/mainwindow_moc.cpp

@@ -28,7 +28,7 @@ void MainWindow::load()
 	QDir::setCurrent(QApplication::applicationDirPath());
 	QDir::setCurrent(QApplication::applicationDirPath());
 
 
 	console = new CConsoleHandler();
 	console = new CConsoleHandler();
-	CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Launcher_log.txt", console);
+	CBasicLogConfigurator logConfig(VCMIDirs::get().userLogsPath() / "VCMI_Launcher_log.txt", console);
 	logConfig.configureDefault();
 	logConfig.configureDefault();
 
 
 	CResourceHandler::initialize();
 	CResourceHandler::initialize();

+ 4 - 0
lib/VCMIDirs.cpp

@@ -13,6 +13,8 @@
 
 
 namespace bfs = boost::filesystem;
 namespace bfs = boost::filesystem;
 
 
+bfs::path IVCMIDirs::userLogsPath() const { return userCachePath(); }
+
 bfs::path IVCMIDirs::userSavePath() const { return userDataPath() / "Saves"; }
 bfs::path IVCMIDirs::userSavePath() const { return userDataPath() / "Saves"; }
 
 
 bfs::path IVCMIDirs::fullLibraryPath(const std::string &desiredFolder, const std::string &baseLibName) const
 bfs::path IVCMIDirs::fullLibraryPath(const std::string &desiredFolder, const std::string &baseLibName) const
@@ -35,6 +37,7 @@ std::string IVCMIDirs::genHelpString() const
 		"  user data:   " + userDataPath().string() + "\n"
 		"  user data:   " + userDataPath().string() + "\n"
 		"  user cache:  " + userCachePath().string() + "\n"
 		"  user cache:  " + userCachePath().string() + "\n"
 		"  user config: " + userConfigPath().string() + "\n"
 		"  user config: " + userConfigPath().string() + "\n"
+		"  user logs:   " + userLogsPath().string() + "\n"
 		"  user saves:  " + userSavePath().string() + "\n"; // Should end without new-line?
 		"  user saves:  " + userSavePath().string() + "\n"; // Should end without new-line?
 }
 }
 
 
@@ -44,6 +47,7 @@ void IVCMIDirs::init()
 	bfs::create_directories(userDataPath());
 	bfs::create_directories(userDataPath());
 	bfs::create_directories(userCachePath());
 	bfs::create_directories(userCachePath());
 	bfs::create_directories(userConfigPath());
 	bfs::create_directories(userConfigPath());
+	bfs::create_directories(userLogsPath());
 	bfs::create_directories(userSavePath());
 	bfs::create_directories(userSavePath());
 }
 }
 
 

+ 3 - 0
lib/VCMIDirs.h

@@ -21,6 +21,9 @@ public:
 	// Path to writeable directory with user configs
 	// Path to writeable directory with user configs
 	virtual boost::filesystem::path userConfigPath() const = 0;
 	virtual boost::filesystem::path userConfigPath() const = 0;
 
 
+	// Path to writeable directory to store log files
+	virtual boost::filesystem::path userLogsPath() const;
+
 	// Path to saved games
 	// Path to saved games
 	virtual boost::filesystem::path userSavePath() const;
 	virtual boost::filesystem::path userSavePath() const;
 
 

+ 1 - 1
server/CVCMIServer.cpp

@@ -915,7 +915,7 @@ int main(int argc, char * argv[])
 #endif
 #endif
 
 
 	console = new CConsoleHandler();
 	console = new CConsoleHandler();
-	CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Server_log.txt", console);
+	CBasicLogConfigurator logConfig(VCMIDirs::get().userLogsPath() / "VCMI_Server_log.txt", console);
 	logConfig.configureDefault();
 	logConfig.configureDefault();
 	logGlobal->info(NAME);
 	logGlobal->info(NAME);