mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 19:24:12 +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:
parent
21e9173415
commit
feae2988d6
@ -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");
|
||||
@ -71,4 +86,4 @@ namespace dxvk {
|
||||
return LogLevel::Info;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace dxvk {
|
||||
Info = 2,
|
||||
Warn = 3,
|
||||
Error = 4,
|
||||
None = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -49,4 +50,4 @@ namespace dxvk {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user