mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-03 15:58:43 +00:00
client: fix logger init mix-up
enable log rotate in case RED_DEBUG is not defined and disable log rotate in case RED_DEBUG is defined
This commit is contained in:
parent
db5375a5f8
commit
0bd3b58bc9
@ -1771,12 +1771,12 @@ void Application::init_logger()
|
||||
#ifdef RED_DEBUG
|
||||
root.setPriority(log4cpp::Priority::DEBUG);
|
||||
root.removeAllAppenders();
|
||||
::close(fd);
|
||||
root.addAppender(new log4cpp::RollingFileAppender("_", log_file_name));
|
||||
root.addAppender(new log4cpp::FileAppender("_", fd));
|
||||
#else
|
||||
root.setPriority(log4cpp::Priority::INFO);
|
||||
root.removeAllAppenders();
|
||||
root.addAppender(new log4cpp::FileAppender("_", fd));
|
||||
::close(fd);
|
||||
root.addAppender(new log4cpp::RollingFileAppender("_", log_file_name));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -430,24 +430,7 @@ bool Platform::is_monitors_pos_valid()
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void Platform::get_spice_config_dir(std::string& path)
|
||||
{
|
||||
char app_data_path[MAX_PATH];
|
||||
HRESULT res = SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, app_data_path);
|
||||
if (res != S_OK) {
|
||||
throw Exception("get user app data dir failed");
|
||||
}
|
||||
|
||||
path = app_data_path;
|
||||
if (strcmp((app_data_path + strlen(app_data_path) - 2), "\\") != 0) {
|
||||
path += "\\";
|
||||
}
|
||||
path += SPICE_CONFIG_DIR;
|
||||
}
|
||||
*/
|
||||
|
||||
static void Platform::get_app_data_dir(std::string& path, const std::string& app_name);
|
||||
void Platform::get_app_data_dir(std::string& path, const std::string& app_name)
|
||||
{
|
||||
char app_data_path[MAX_PATH];
|
||||
HRESULT res = SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, app_data_path);
|
||||
@ -458,12 +441,12 @@ static void Platform::get_app_data_dir(std::string& path, const std::string& app
|
||||
path = app_data_path;
|
||||
path_append(path, app_name);
|
||||
|
||||
if (!CreateDirectory(path.c_str()) && GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
if (!CreateDirectoryA(path.c_str(), NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
throw Exception("create user app data dir failed");
|
||||
}
|
||||
}
|
||||
|
||||
static void Platform::path_append(std::string& path, const std::string& partial_path)
|
||||
void Platform::path_append(std::string& path, const std::string& partial_path)
|
||||
{
|
||||
path += "\\";
|
||||
path += partial_path;
|
||||
|
||||
@ -1899,11 +1899,17 @@ void Platform::get_app_data_dir(std::string& path, const std::string& app_name)
|
||||
{
|
||||
const char* home_dir = getenv("HOME");
|
||||
|
||||
if (!home_dir) {
|
||||
if (!home_dir || strlen(home_dir) == 0) {
|
||||
throw Exception("get home dir failed");
|
||||
}
|
||||
|
||||
path = home_dir;
|
||||
std::string::iterator end = path.end();
|
||||
|
||||
while (end != path.begin() && *(end - 1) == '/') {
|
||||
path.erase(--end);
|
||||
}
|
||||
|
||||
path += "/.";
|
||||
path += app_name;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user