Skip to content

Commit

Permalink
[util] Add option to disable log files entirely
Browse files Browse the repository at this point in the history
But still log to stderr. Fixes #1743.
  • Loading branch information
doitsujin committed Aug 24, 2020
1 parent 16a51f3 commit 645c8f8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/util/log/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ namespace dxvk {

Logger::Logger(const std::string& file_name)
: m_minLevel(getMinLogLevel()) {
if (m_minLevel != LogLevel::None)
m_fileStream = std::ofstream(getFileName(file_name));
if (m_minLevel != LogLevel::None) {
auto path = getFileName(file_name);

if (!path.empty())
m_fileStream = std::ofstream(path);
}
}


Expand Down Expand Up @@ -57,8 +61,10 @@ namespace dxvk {
std::string line;

while (std::getline(stream, line, '\n')) {
std::cerr << prefix << line << std::endl;
m_fileStream << prefix << line << std::endl;
std::cerr << prefix << line << std::endl;

if (m_fileStream)
m_fileStream << prefix << line << std::endl;
}
}
}
Expand Down Expand Up @@ -88,9 +94,12 @@ namespace dxvk {
std::string Logger::getFileName(const std::string& base) {
std::string path = env::getEnvVar("DXVK_LOG_PATH");

if (path == "none")
return "";

if (!path.empty() && *path.rbegin() != '/')
path += '/';

std::string exeName = env::getExeName();
auto extp = exeName.find_last_of('.');

Expand Down

0 comments on commit 645c8f8

Please sign in to comment.