1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-08 10:46:09 +01:00
dxvk/src/util/log/log.h

63 lines
1.2 KiB
C
Raw Normal View History

2017-10-10 23:32:13 +02:00
#pragma once
#include <array>
2017-10-10 23:32:13 +02:00
#include <fstream>
#include <iostream>
#include <mutex>
#include <string>
namespace dxvk {
enum class LogLevel : uint32_t {
Trace = 0,
Debug = 1,
Info = 2,
Warn = 3,
Error = 4,
None = 5,
};
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);
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
static LogLevel logLevel() {
return s_instance.m_minLevel;
}
2017-10-10 23:32:13 +02:00
private:
static Logger s_instance;
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);
static LogLevel getMinLogLevel();
static std::string getFileName(
const std::string& base);
2017-10-10 23:44:06 +02:00
2017-10-10 23:32:13 +02:00
};
}