diff --git a/src/util/log/log.cpp b/src/util/log/log.cpp index 1f8571e88..47ab5af25 100644 --- a/src/util/log/log.cpp +++ b/src/util/log/log.cpp @@ -5,8 +5,22 @@ namespace dxvk { Logger::Logger(const std::string& file_name) - : m_minLevel(getMinLogLevel()), - m_fileStream(file_name) { } + : m_minLevel(getMinLogLevel()) + { + if (m_minLevel == LogLevel::None) + return; + + std::string path = env::getEnvVar(L"DXVK_LOG_PATH"); + std::string file = path; + if (!file.empty() && *file.rbegin() != '/') + file += '/'; + std::string name = env::getExeName(); + auto extp = name.find_last_of('.'); + if (extp != std::string::npos && name.substr(extp +1) == "exe") + name.erase(extp); + file += name + "_"; + m_fileStream = std::ofstream(file + file_name); + } Logger::~Logger() { } @@ -53,12 +67,13 @@ namespace dxvk { LogLevel Logger::getMinLogLevel() { - const std::array, 5> logLevels = {{ + const std::array, 6> logLevels = {{ { "trace", LogLevel::Trace }, { "debug", LogLevel::Debug }, { "info", LogLevel::Info }, { "warn", LogLevel::Warn }, { "error", LogLevel::Error }, + { "none", LogLevel::None }, }}; const std::string logLevelStr = env::getEnvVar(L"DXVK_LOG_LEVEL"); @@ -71,4 +86,4 @@ namespace dxvk { return LogLevel::Info; } -} \ No newline at end of file +} diff --git a/src/util/log/log.h b/src/util/log/log.h index c39bf0bba..e298765ae 100644 --- a/src/util/log/log.h +++ b/src/util/log/log.h @@ -13,6 +13,7 @@ namespace dxvk { Info = 2, Warn = 3, Error = 4, + None = 5, }; /** @@ -49,4 +50,4 @@ namespace dxvk { }; -} \ No newline at end of file +}