mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 16:34:17 +00:00
53 lines
917 B
C++
53 lines
917 B
C++
#ifndef LOGGER_HPP
|
|
#define LOGGER_HPP
|
|
|
|
#include <iostream>
|
|
|
|
// log file
|
|
namespace core::log
|
|
{
|
|
enum Type
|
|
{
|
|
INFO,
|
|
ERROR,
|
|
WARNING
|
|
};
|
|
|
|
static inline const char *getErrorType(Type type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case INFO:
|
|
return "INFO";
|
|
case ERROR:
|
|
return "ERROR";
|
|
case WARNING:
|
|
return "WARNING";
|
|
}
|
|
return "UNKNOWN";
|
|
}
|
|
|
|
inline void log(Type type, const char *desc, int errortype = 0)
|
|
{
|
|
std::cerr << getErrorType(type) << " ERROR"
|
|
<< ((errortype) ? std::format("({})", errortype) : "") << ": "
|
|
<< desc << std::endl;
|
|
}
|
|
|
|
inline void info(const char *desc, int codeerror = 0)
|
|
{
|
|
log(Type::INFO, desc, codeerror);
|
|
}
|
|
|
|
inline void error(const char *desc, int codeerror = 0)
|
|
{
|
|
log(Type::ERROR, desc, codeerror);
|
|
}
|
|
|
|
inline void warning(const char *desc, int codeerror = 0)
|
|
{
|
|
log(Type::WARNING, desc, codeerror);
|
|
}
|
|
}; // namespace core::log
|
|
|
|
#endif // LOGGER_HPP
|