2017-10-10 23:32:13 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-06 18:34:34 +01:00
|
|
|
#include <array>
|
2017-10-10 23:32:13 +02:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2018-01-12 00:05:09 +01:00
|
|
|
enum class LogLevel : uint32_t {
|
|
|
|
Trace = 0,
|
|
|
|
Debug = 1,
|
|
|
|
Info = 2,
|
|
|
|
Warn = 3,
|
|
|
|
Error = 4,
|
2018-01-23 13:36:31 +01:00
|
|
|
None = 5,
|
2018-01-12 00:05:09 +01:00
|
|
|
};
|
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
/**
|
|
|
|
* \brief Logger
|
|
|
|
*
|
2017-10-10 23:44:06 +02:00
|
|
|
* Logger for one DLL. Creates a text file and
|
|
|
|
* writes all log messages to that file.
|
2017-10-10 23:32:13 +02:00
|
|
|
*/
|
2017-10-10 23:44:06 +02:00
|
|
|
class Logger {
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-10-10 23:44:06 +02:00
|
|
|
Logger(const std::string& file_name);
|
|
|
|
~Logger();
|
2017-10-10 23:32:13 +02:00
|
|
|
|
2017-10-10 23:44:06 +02:00
|
|
|
static void trace(const std::string& message);
|
2018-01-12 00:05:09 +01:00
|
|
|
static void debug(const std::string& message);
|
2017-10-10 23:44:06 +02:00
|
|
|
static void info (const std::string& message);
|
|
|
|
static void warn (const std::string& message);
|
|
|
|
static void err (const std::string& message);
|
2018-04-02 19:05:20 +02:00
|
|
|
static void log (LogLevel level, const std::string& message);
|
2017-10-10 23:32:13 +02:00
|
|
|
|
2018-02-07 16:44:30 +01:00
|
|
|
static LogLevel logLevel() {
|
|
|
|
return s_instance.m_minLevel;
|
|
|
|
}
|
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
private:
|
|
|
|
|
2017-12-06 23:36:11 +01:00
|
|
|
static Logger s_instance;
|
|
|
|
|
2018-01-12 00:05:09 +01:00
|
|
|
const LogLevel m_minLevel;
|
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
std::mutex m_mutex;
|
2017-10-10 23:44:06 +02:00
|
|
|
std::ofstream m_fileStream;
|
2017-10-10 23:32:13 +02:00
|
|
|
|
2018-04-02 19:05:20 +02:00
|
|
|
void emitMsg(LogLevel level, const std::string& message);
|
2018-01-12 00:05:09 +01:00
|
|
|
|
|
|
|
static LogLevel getMinLogLevel();
|
2018-01-29 20:01:49 +01:00
|
|
|
|
|
|
|
static std::string getFileName(
|
|
|
|
const std::string& base);
|
2017-10-10 23:44:06 +02:00
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
};
|
|
|
|
|
2018-01-23 13:36:31 +01:00
|
|
|
}
|