2018-08-03 09:19:12 +00:00
|
|
|
#ifndef DEBUG_LOG_H
|
|
|
|
#define DEBUG_LOG_H
|
|
|
|
|
2022-06-29 21:08:33 +00:00
|
|
|
#include <filesystem>
|
2018-08-03 09:19:12 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace Debug
|
|
|
|
{
|
|
|
|
enum Level
|
|
|
|
{
|
|
|
|
Error = 1,
|
|
|
|
Warning = 2,
|
|
|
|
Info = 3,
|
|
|
|
Verbose = 4,
|
2018-11-01 10:08:33 +00:00
|
|
|
Debug = 5,
|
|
|
|
Marker = Debug,
|
2018-10-12 10:11:41 +00:00
|
|
|
|
2018-11-01 10:08:33 +00:00
|
|
|
NoLevel = 6 // Do not filter messages in this case
|
2018-08-03 09:19:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Level CurrentDebugLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Log
|
|
|
|
{
|
|
|
|
public:
|
2022-06-06 22:36:08 +00:00
|
|
|
explicit Log(Debug::Level level);
|
|
|
|
~Log();
|
2018-08-03 09:19:12 +00:00
|
|
|
|
|
|
|
template <typename T>
|
2023-02-06 20:18:35 +00:00
|
|
|
Log& operator<<(const T& rhs)
|
2018-08-03 09:19:12 +00:00
|
|
|
{
|
2021-11-07 18:47:02 +00:00
|
|
|
if (mShouldLog)
|
2023-02-06 20:18:35 +00:00
|
|
|
std::cout << rhs;
|
2018-08-03 09:19:12 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2022-06-29 21:08:33 +00:00
|
|
|
Log& operator<<(const std::filesystem::path& rhs);
|
|
|
|
|
2023-02-06 20:18:35 +00:00
|
|
|
Log& operator<<(const std::u8string& rhs);
|
2022-06-29 21:08:33 +00:00
|
|
|
|
2022-09-10 10:11:56 +00:00
|
|
|
Log& operator<<(std::u8string_view rhs);
|
2022-06-29 21:08:33 +00:00
|
|
|
|
|
|
|
Log& operator<<(const char8_t* rhs);
|
|
|
|
|
2018-08-03 09:19:12 +00:00
|
|
|
private:
|
2021-11-07 18:47:02 +00:00
|
|
|
const bool mShouldLog;
|
2018-08-03 09:19:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|