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:
parent
16c1b9ed73
commit
d4ce5b86ec
@ -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>();
|
||||
|
@ -451,47 +451,47 @@ 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)
|
||||
{
|
||||
// Initialize ringbuffer
|
||||
m_fptr = std::make_unique<uchar[]>(s_log_size);
|
||||
return;
|
||||
}
|
||||
|
||||
// Actual log file (allowed to fail)
|
||||
if (!m_fout.open(name, fs::rewrite))
|
||||
{
|
||||
fprintf(stderr, "Log file open failed: %s (error %d)\n", name.c_str(), errno);
|
||||
}
|
||||
// Initialize ringbuffer
|
||||
m_fptr = std::make_unique<uchar[]>(s_log_size);
|
||||
|
||||
// Compressed log, make it inaccessible (foolproof)
|
||||
if (m_fout2.open(name + ".gz", fs::rewrite + fs::unread))
|
||||
{
|
||||
// Actual log file (allowed to fail)
|
||||
if (!m_fout.open(name, fs::rewrite))
|
||||
{
|
||||
fprintf(stderr, "Log file open failed: %s (error %d)\n", name.c_str(), errno);
|
||||
}
|
||||
|
||||
// Compressed log, make it inaccessible (foolproof)
|
||||
if (m_fout2.open(name + ".gz", fs::rewrite + fs::unread))
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
if (deflateInit2(&m_zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
if (deflateInit2(&m_zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
#ifndef _MSC_VER
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
m_fout2.close();
|
||||
}
|
||||
|
||||
if (!m_fout2)
|
||||
{
|
||||
fprintf(stderr, "Log file open failed: %s.gz (error %d)\n", name.c_str(), errno);
|
||||
m_fout2.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_fout2)
|
||||
{
|
||||
fprintf(stderr, "Log file open failed: %s.gz (error %d)\n", name.c_str(), errno);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Autodelete compressed log file
|
||||
FILE_DISPOSITION_INFO disp;
|
||||
disp.DeleteFileW = true;
|
||||
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
|
||||
// Autodelete compressed log file
|
||||
FILE_DISPOSITION_INFO disp{};
|
||||
disp.DeleteFileW = true;
|
||||
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_writer = std::thread([this]()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user