1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Improve log file creation error message

Early out in file_writer ctor instead of large if else
This commit is contained in:
Megamouse 2024-10-14 20:06:17 +02:00
parent 16c1b9ed73
commit d4ce5b86ec
2 changed files with 34 additions and 33 deletions

View File

@ -494,6 +494,7 @@ int main(int argc, char** argv)
}
const std::string lock_name = fs::get_cache_dir() + "RPCS3.buf";
const std::string log_name = fs::get_cache_dir() + "RPCS3.log";
static fs::file instance_lock;
@ -512,19 +513,19 @@ int main(int argc, char** argv)
{
if (fs::exists(lock_name))
{
report_fatal_error("Another instance of RPCS3 is running.\nClose it or kill its process, if necessary.");
report_fatal_error(fmt::format("Another instance of RPCS3 is running.\nClose it or kill its process, if necessary.\n'%s' still exists.", lock_name));
}
report_fatal_error("Cannot create RPCS3.log (access denied)."
report_fatal_error(fmt::format("Cannot create '%s' or '%s' (access denied).\n"
#ifdef _WIN32
"\nNote that RPCS3 cannot be installed in Program Files or similar directories with limited permissions."
"Note that RPCS3 cannot be installed in Program Files or similar directories with limited permissions."
#else
"\nPlease, check RPCS3 permissions in '~/.config/rpcs3'."
"Please, check RPCS3 permissions."
#endif
);
, log_name, lock_name));
}
report_fatal_error(fmt::format("Cannot create RPCS3.log (error %s)", fs::g_tls_error));
report_fatal_error(fmt::format("Cannot create'%s' or '%s' (error=%s)", log_name, lock_name, fs::g_tls_error));
}
#ifdef _WIN32
@ -568,7 +569,7 @@ int main(int argc, char** argv)
}
// Limit log size to ~25% of free space
log_file = logs::make_file_listener(fs::get_cache_dir() + "RPCS3.log", stats.avail_free / 4);
log_file = logs::make_file_listener(log_name, stats.avail_free / 4);
}
static std::unique_ptr<logs::listener> fatal_listener = std::make_unique<fatal_error_listener>();

View File

@ -451,8 +451,11 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co
logs::file_writer::file_writer(const std::string& name, u64 max_size)
: m_max_size(max_size)
{
if (!name.empty() && max_size)
if (name.empty() || !max_size)
{
return;
}
// Initialize ringbuffer
m_fptr = std::make_unique<uchar[]>(s_log_size);
@ -473,8 +476,10 @@ logs::file_writer::file_writer(const std::string& name, u64 max_size)
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
{
m_fout2.close();
}
}
if (!m_fout2)
{
@ -483,15 +488,10 @@ logs::file_writer::file_writer(const std::string& name, u64 max_size)
#ifdef _WIN32
// Autodelete compressed log file
FILE_DISPOSITION_INFO disp;
FILE_DISPOSITION_INFO disp{};
disp.DeleteFileW = true;
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
#endif
}
else
{
return;
}
m_writer = std::thread([this]()
{