1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 13:24:20 +01:00

Improvements for log files (#22)

* Improvements for log files
 - Added exec name to log files
 - Added DXVK_LOG_PATH environment variable to specify the log folder
* Remove .exe from log name
* log: add log level none
* log: corrected type for string position
This commit is contained in:
Raffarti 2018-01-23 13:36:31 +01:00 committed by Philip Rebohle
parent 21e9173415
commit feae2988d6
2 changed files with 21 additions and 5 deletions

View File

@ -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<std::pair<const char*, LogLevel>, 5> logLevels = {{
const std::array<std::pair<const char*, LogLevel>, 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");

View File

@ -13,6 +13,7 @@ namespace dxvk {
Info = 2,
Warn = 3,
Error = 4,
None = 5,
};
/**