mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-06 20:58:37 +01:00
[util] Add option to disable log files entirely
But still log to stderr. Fixes #1743.
This commit is contained in:
parent
16a51f3c03
commit
645c8f8177
1 changed files with 14 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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('.');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue