blob: a6c6ea2f7c27053a049fce6ca774d05c6a730e75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#pragma once
#include "format.hpp"
#include <chrono>
#include <format>
#include <print>
#include <string>
enum eLogLevel : int8_t {
INFO = 0,
WARN,
ERROR,
FATAL
};
inline bool useColors = true;
void log(eLogLevel level, std::string str);
template <typename... Args>
void log(eLogLevel level, std::format_string<Args...> fmt, Args &&...args) {
const auto now = std::chrono::system_clock::now();
const auto hms = std::chrono::hh_mm_ss{now - std::chrono::floor<std::chrono::days>(now)};
std::string timeStamp = std::format("[{}] ", hms);
std::string msg = CFormatter::fmt(eFormatType::RAW, fmt, std::forward<Args>(args)...);
log(level, timeStamp + msg);
}
|