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