mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-06 20:58:37 +01:00
Improvements for log files
- Added exec name to log files - Added DXVK_LOG_PATH environment variable to specify the log folder - Added DXVK_LOG_TIMESTAMP environment variable to add timestamps to file names
This commit is contained in:
parent
650170b167
commit
abfe66b48a
1 changed files with 20 additions and 3 deletions
|
@ -2,11 +2,28 @@
|
|||
|
||||
#include "../util_env.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
Logger::Logger(const std::string& file_name)
|
||||
: m_minLevel(getMinLogLevel()),
|
||||
m_fileStream(file_name) { }
|
||||
: m_minLevel(getMinLogLevel())
|
||||
{
|
||||
std::string path = env::getEnvVar(L"DXVK_LOG_PATH");
|
||||
std::string file = path;
|
||||
if (!file.empty() && *file.rbegin() != '/')
|
||||
file += '/';
|
||||
file += env::getExeName() + "_";
|
||||
if (!env::getEnvVar(L"DXVK_LOG_TIMESTAMP").empty()) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
char mbstr[sizeof("2018-01-01_00.00.00")];
|
||||
if (std::strftime(mbstr, sizeof(mbstr), "%Y-%m-%d_%H.%M.%S", std::localtime(&t))) {
|
||||
file += std::string(mbstr) + "_";
|
||||
}
|
||||
}
|
||||
|
||||
m_fileStream = std::ofstream(file + file_name);
|
||||
}
|
||||
|
||||
|
||||
Logger::~Logger() { }
|
||||
|
@ -71,4 +88,4 @@ namespace dxvk {
|
|||
return LogLevel::Info;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue