27#define TERMCOLOR_USE_ANSI_ESCAPE_SEQUENCES
30#include <termcolor/termcolor.hpp>
49 constexpr static auto rc = termcolor::reset;
54 constexpr static auto tc = termcolor::color<87>;
59 constexpr static auto lc = termcolor::color<249>;
64 constexpr static auto ic = termcolor::color<116>;
69 constexpr static auto wc = termcolor::color<220>;
74 constexpr static auto ec = termcolor::color<198>;
79 constexpr static auto fc = termcolor::color<85>;
84 constexpr static auto lic = termcolor::color<86>;
89 constexpr static auto dc = termcolor::color<241>;
115 void load(
const std::string& applicationName);
150 template <
typename T>
void log(
T msg) {
153 std::lock_guard<std::mutex> guard(
mutex);
155 std::cout << dc <<
"[" << tc << time << dc <<
"] " <<
156 lc << msg <<
"\n" << rc;
159 logFile <<
"[" << time <<
"] " << msg << std::endl;
166 template <
typename T>
void info(
T msg) {
169 std::lock_guard<std::mutex> guard(
mutex);
171 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
172 ic <<
"INFO" << dc <<
"] " << ic << msg <<
"\n" << rc;
175 logFile <<
"[" << time <<
"] " <<
"[INFO] " << msg << std::endl;
182 template <
typename T>
void warn(
T msg) {
185 std::lock_guard<std::mutex> guard(
mutex);
187 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
188 wc <<
"WARNING" << dc <<
"] " << wc << msg <<
"\n" << rc;
191 logFile <<
"[" << time <<
"] " <<
"[WARNING] " << msg << std::endl;
198 template <
typename T>
void error(
T msg) {
201 std::lock_guard<std::mutex> guard(
mutex);
203 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
204 ec <<
"ERROR" << dc <<
"] " << ec << msg <<
"\n" << rc;
207 logFile <<
"[" << time <<
"] " <<
"[ERROR] " << msg << std::endl;
216 template <
typename T>
void log(
unsigned int line,
const char* file,
T msg) {
219 std::lock_guard<std::mutex> guard(
mutex);
221 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
222 fc << file << dc <<
":" << lic << line << dc <<
"] " <<
223 lc << msg <<
"\n" << rc;
226 logFile <<
"[" << time <<
"] " <<
"[" << file <<
":" << line <<
"] " << msg << std::endl;
235 template <
typename T>
void info(
unsigned int line,
const char* file,
T msg) {
238 std::lock_guard<std::mutex> guard(
mutex);
240 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
241 fc << file << dc <<
":" << lic << line << dc <<
"] [" <<
242 ic <<
"INFO" << dc <<
"] " <<
243 ic << msg <<
"\n" << rc;
246 logFile <<
"[" << time <<
"] " <<
"[" << file <<
":" << line <<
"] " <<
"[INFO] " << msg << std::endl;
255 template <
typename T>
void warn(
unsigned int line,
const char* file,
T msg) {
258 std::lock_guard<std::mutex> guard(
mutex);
260 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
261 fc << file << dc <<
":" << lic << line << dc <<
"] [" <<
262 wc <<
"WARNING" << dc <<
"] " <<
263 wc << msg <<
"\n" << rc;
266 logFile <<
"[" << time <<
"] " <<
"[" << file <<
":" << line <<
"] " <<
"[WARNING] " << msg << std::endl;
275 template <
typename T>
void error(
unsigned int line,
const char* file,
T msg) {
278 std::lock_guard<std::mutex> guard(
mutex);
280 std::cout << dc <<
"[" << tc << time << dc <<
"] [" <<
281 fc << file << dc <<
":" << lic << line << dc <<
"] [" <<
282 ec <<
"ERROR" << dc <<
"] " <<
283 ec << msg <<
"\n" << rc;
286 logFile <<
"[" << time <<
"] " <<
"[" << file <<
":" << line <<
"] " <<
"[ERROR] " << msg << std::endl;
295 template <
typename T>
void assertCheck(
unsigned int line,
const char* file,
T assertion) {
296 if (assertion)
return;
297 error(line, file,
"Assertion Failed");
307 template <
typename T,
typename STR>
void assertCheck(
unsigned int line,
const char* file,
T assertion, STR msg) {
308 using namespace std::string_literals;
309 if (assertion)
return;
310 error(line, file,
"Assertion Failed - "s + msg);
324#define __FILENAME__ strrchr("\\" __FILE__, '\\') + 1
326#define __FILENAME__ strrchr("/" __FILE__, '/') + 1
332#define klPrint(x) Kale::console.log(__LINE__, __FILENAME__, x)
337#define klInfo(x) Kale::console.info(__LINE__, __FILENAME__, x)
342#define klWarn(x) Kale::console.warn(__LINE__, __FILENAME__, x)
347#define klError(x) Kale::console.error(__LINE__, __FILENAME__, x)
352#define klAssert(x) Kale::console.assertCheck(__LINE__, __FILENAME__, x)
357#define klAssertMsg(x, y) Kale::console.assertCheck(__LINE__, __FILENAME__, x, y)
void log(unsigned int line, const char *file, T msg)
std::string getTimePrefix()
Logger(const Logger &other)=delete
void error(unsigned int line, const char *file, T msg)
void info(unsigned int line, const char *file, T msg)
void load(const std::string &applicationName)
Logger(Logger &&other)=delete
void assertCheck(unsigned int line, const char *file, T assertion)
void warn(unsigned int line, const char *file, T msg)
void operator=(Logger &&other)=delete
void assertCheck(unsigned int line, const char *file, T assertion, STR msg)
void operator=(const Logger &other)=delete