1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[util] Add option to disable log files entirely

But still log to stderr. Fixes #1743.
This commit is contained in:
Philip Rebohle 2020-08-24 09:09:18 +02:00
parent 16a51f3c03
commit 645c8f8177

View File

@ -6,8 +6,12 @@ namespace dxvk {
Logger::Logger(const std::string& file_name) Logger::Logger(const std::string& file_name)
: m_minLevel(getMinLogLevel()) { : m_minLevel(getMinLogLevel()) {
if (m_minLevel != LogLevel::None) if (m_minLevel != LogLevel::None) {
m_fileStream = std::ofstream(getFileName(file_name)); auto path = getFileName(file_name);
if (!path.empty())
m_fileStream = std::ofstream(path);
}
} }
@ -57,8 +61,10 @@ namespace dxvk {
std::string line; std::string line;
while (std::getline(stream, line, '\n')) { while (std::getline(stream, line, '\n')) {
std::cerr << prefix << line << std::endl; std::cerr << prefix << line << std::endl;
m_fileStream << prefix << line << std::endl;
if (m_fileStream)
m_fileStream << prefix << line << std::endl;
} }
} }
} }
@ -88,9 +94,12 @@ namespace dxvk {
std::string Logger::getFileName(const std::string& base) { std::string Logger::getFileName(const std::string& base) {
std::string path = env::getEnvVar("DXVK_LOG_PATH"); std::string path = env::getEnvVar("DXVK_LOG_PATH");
if (path == "none")
return "";
if (!path.empty() && *path.rbegin() != '/') if (!path.empty() && *path.rbegin() != '/')
path += '/'; path += '/';
std::string exeName = env::getExeName(); std::string exeName = env::getExeName();
auto extp = exeName.find_last_of('.'); auto extp = exeName.find_last_of('.');