mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 16:24:29 +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 {
|
namespace dxvk {
|
||||||
|
|
||||||
Logger::Logger(const std::string& file_name)
|
Logger::Logger(const std::string& file_name)
|
||||||
: m_minLevel(getMinLogLevel()),
|
: m_minLevel(getMinLogLevel())
|
||||||
m_fileStream(file_name) { }
|
{
|
||||||
|
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() { }
|
Logger::~Logger() { }
|
||||||
@ -53,12 +67,13 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
LogLevel Logger::getMinLogLevel() {
|
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 },
|
{ "trace", LogLevel::Trace },
|
||||||
{ "debug", LogLevel::Debug },
|
{ "debug", LogLevel::Debug },
|
||||||
{ "info", LogLevel::Info },
|
{ "info", LogLevel::Info },
|
||||||
{ "warn", LogLevel::Warn },
|
{ "warn", LogLevel::Warn },
|
||||||
{ "error", LogLevel::Error },
|
{ "error", LogLevel::Error },
|
||||||
|
{ "none", LogLevel::None },
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const std::string logLevelStr = env::getEnvVar(L"DXVK_LOG_LEVEL");
|
const std::string logLevelStr = env::getEnvVar(L"DXVK_LOG_LEVEL");
|
||||||
|
@ -13,6 +13,7 @@ namespace dxvk {
|
|||||||
Info = 2,
|
Info = 2,
|
||||||
Warn = 3,
|
Warn = 3,
|
||||||
Error = 4,
|
Error = 4,
|
||||||
|
None = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user