consolidate as much as possible
This commit is contained in:
@@ -17,11 +17,11 @@ include(cmake/CPM.cmake)
|
||||
file(GLOB_RECURSE jlog_HEADERS "include/jlog/*.h" "include/jlog/*.hpp")
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
file(GLOB_RECURSE jlog_SRC "src/jlog/linux/*.c" "src/jlog/linux/*.cpp")
|
||||
file(GLOB_RECURSE jlog_SRC "src/jlog/linux/*.c" "src/jlog/linux/*.cpp" "src/jlog/shared/*.c" "src/jlog/shared/*.cpp")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
file(GLOB_RECURSE jlog_SRC "src/jlog/windows/*.c" "src/jlog/windows/*.cpp")
|
||||
file(GLOB_RECURSE jlog_SRC "src/jlog/windows/*.c" "src/jlog/windows/*.cpp" "src/jlog/shared/*.c" "src/jlog/shared/*.cpp")
|
||||
endif()
|
||||
|
||||
include_directories("include")
|
||||
|
@@ -11,6 +11,7 @@ jlog is a C++ library for logging to file, console, and event callbacks.
|
||||
* Color Output
|
||||
* Logs to file AND console!
|
||||
* Idiomatic Event callback for hooking into your game engine gui!
|
||||
* GCC and MSVC support
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -29,6 +30,7 @@ target_link_libraries(YourProgram ... jlog)
|
||||
|
||||
```
|
||||
|
||||
# Usage
|
||||
Using jlog is straightforward:
|
||||
|
||||
```cpp
|
||||
|
@@ -6,6 +6,10 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef WORD
|
||||
#define WORD short
|
||||
#endif
|
||||
|
||||
namespace jlog::nt_color_codes
|
||||
{
|
||||
const WORD FG_BLACK = 0x0000;
|
||||
@@ -48,8 +52,4 @@ namespace jlog::nt_color_codes
|
||||
const WORD BG_BRIGHT_WHITE = BG_RED | BG_GREEN | BG_BLUE | 0x0080;
|
||||
|
||||
const WORD BG_DEFAULT = BG_WHITE;
|
||||
|
||||
inline void SetConsoleTextColor(WORD color) {
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
|
||||
}
|
||||
}
|
@@ -1,178 +1,17 @@
|
||||
#include <source_location>
|
||||
|
||||
#include <jlog/jlog.hpp>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
namespace jlog {
|
||||
|
||||
std::string get_timestamp()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto const timestamp = current_zone()->to_local(system_clock::now());
|
||||
auto dp = floor<days>(timestamp);
|
||||
year_month_day ymd{floor<days>(timestamp)};
|
||||
hh_mm_ss time{floor<milliseconds>(timestamp-dp)};
|
||||
auto y = ymd.year();
|
||||
auto m = ymd.month();
|
||||
auto d = ymd.day();
|
||||
auto h = time.hours();
|
||||
auto M = time.minutes();
|
||||
auto s = time.seconds();
|
||||
auto ms = time.subseconds();
|
||||
return std::format("{}-{}-{} {}:{}:{}.{}", y, m, d, h.count(), M.count(), s.count(), ms.count());
|
||||
}
|
||||
|
||||
void log_to_console(const std::string &message)
|
||||
{
|
||||
std::cout << message;
|
||||
}
|
||||
|
||||
void log_to_file(const std::string &message)
|
||||
{
|
||||
std::ofstream latest_log("latest.log", std::ios_base::app);
|
||||
latest_log << message;
|
||||
latest_log.close();
|
||||
|
||||
}
|
||||
|
||||
void log(std::vector<token> tokens) {
|
||||
for (token t : tokens) {
|
||||
if (t.delimiter != "") {
|
||||
log_to_console(std::format("{}{}{}{}{} ", t.colorCode, t.delimiter[0], t.content, t.delimiter[1], ansi_escape_codes::RESET));
|
||||
for (token t: tokens) {
|
||||
if (!t.delimiter.empty())
|
||||
log_to_console(std::format("{}{}{}{}{} ", t.colorCode.ansi_code, t.delimiter[0], t.content, t.delimiter[1], ansi_escape_codes::RESET)),
|
||||
log_to_file(std::format("{}{}{} ", t.delimiter[0], t.content, t.delimiter[1]));
|
||||
} else {
|
||||
log_to_console(std::format("{}{}{} ", t.colorCode, t.content, ansi_escape_codes::RESET));
|
||||
|
||||
else
|
||||
log_to_console(std::format("{}{}{} ", t.colorCode.ansi_code, t.content, ansi_escape_codes::RESET)),
|
||||
log_to_file(t.content + " ");
|
||||
}
|
||||
}
|
||||
log_to_console("\n");
|
||||
log_to_file("\n");
|
||||
}
|
||||
|
||||
// Generic formatters for building loggers.
|
||||
std::vector<token> trace_format(
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
return {trace, filedata};
|
||||
}
|
||||
|
||||
std::vector<token> log_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const colorcode& severity_colorCode)
|
||||
{
|
||||
auto severity = token{.colorCode = severity_colorCode, .content = severity_name};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
return {severity, content};
|
||||
}
|
||||
|
||||
std::vector<token> log_detailed_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line,
|
||||
const colorcode& severity_colorCode)
|
||||
{
|
||||
std::vector<token> tokens;
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto tf_tokens = trace_format(func, file, line);
|
||||
auto lf_tokens = log_format(severity_name, message, severity_colorCode);
|
||||
tokens.push_back(timestamp);
|
||||
tokens.insert(tokens.end(), tf_tokens.begin(), tf_tokens.end());
|
||||
tokens.insert(tokens.end(), lf_tokens.begin(), lf_tokens.end());
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Predefined generic loggers for jlog.
|
||||
std::vector<token> info_format(const std::string& message)
|
||||
{
|
||||
return log_format("INFO", message);
|
||||
}
|
||||
|
||||
std::vector<token> info_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("INFO", message, func, file, line);
|
||||
}
|
||||
|
||||
std::vector<token> warning_format(const std::string& message)
|
||||
{
|
||||
return log_format("INFO", message, color_codes::FG_YELLOW);
|
||||
}
|
||||
|
||||
std::vector<token> warning_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("WARNING", message, func, file, line, color_codes::FG_YELLOW);
|
||||
}
|
||||
|
||||
std::vector<token> error_format(const std::string& message)
|
||||
{
|
||||
return log_format("ERROR", message, color_codes::FG_RED);
|
||||
}
|
||||
|
||||
std::vector<token> error_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("ERROR", message, func, file, line, color_codes::FG_RED);
|
||||
}
|
||||
|
||||
std::vector<token> fatal_format(const std::string& message)
|
||||
{
|
||||
return log_format("FATAL", message, color_codes::FG_BRIGHT_RED);
|
||||
}
|
||||
|
||||
std::vector<token> fatal_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("FATAL", message, func, file, line, color_codes::FG_BRIGHT_RED);
|
||||
}
|
||||
|
||||
std::vector<token> verbose_format(const std::string& message)
|
||||
{
|
||||
return log_format("VERBOSE", message, ansi_escape_codes::FG_CYAN);
|
||||
}
|
||||
|
||||
std::vector<token> verbose_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("VERBOSE", message, func, file, line, color_codes::FG_CYAN);
|
||||
}
|
||||
|
||||
std::vector<token> debug_format(const std::string& message)
|
||||
{
|
||||
return log_format("DEBUG", message, ansi_escape_codes::FG_GREEN);
|
||||
}
|
||||
|
||||
std::vector<token> debug_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("DEBUG", message, func, file, line, color_codes::FG_GREEN);
|
||||
}
|
||||
}
|
||||
}
|
454
src/jlog/shared/jlog.cpp
Normal file
454
src/jlog/shared/jlog.cpp
Normal file
@@ -0,0 +1,454 @@
|
||||
#include <jlog/jlog.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
namespace jlog
|
||||
{
|
||||
std::string get_timestamp()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto const timestamp = current_zone()->to_local(system_clock::now());
|
||||
auto dp = floor<days>(timestamp);
|
||||
year_month_day ymd{floor<days>(timestamp)};
|
||||
hh_mm_ss time{floor<milliseconds>(timestamp - dp)};
|
||||
auto y = ymd.year();
|
||||
auto m = ymd.month();
|
||||
auto d = ymd.day();
|
||||
auto h = time.hours();
|
||||
auto M = time.minutes();
|
||||
auto s = time.seconds();
|
||||
auto ms = time.subseconds();
|
||||
return std::format("{}-{}-{} {}:{}:{}.{}", y, m, d, h.count(), M.count(), s.count(), ms.count());
|
||||
}
|
||||
|
||||
void log_to_console(const std::string& message)
|
||||
{
|
||||
std::cout << message;
|
||||
}
|
||||
|
||||
void log_to_file(const std::string& message)
|
||||
{
|
||||
std::ofstream latest_log("latest.log", std::ios_base::app);
|
||||
latest_log << message;
|
||||
latest_log.close();
|
||||
}
|
||||
|
||||
std::vector<token> trace_format(
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
return {trace, filedata};
|
||||
}
|
||||
|
||||
std::vector<token> info_format(const std::string& message)
|
||||
{
|
||||
return log_format("INFO", message);
|
||||
}
|
||||
|
||||
std::vector<token> warning_format(const std::string& message)
|
||||
{
|
||||
return log_format("INFO", message, color_codes::FG_YELLOW);
|
||||
}
|
||||
|
||||
std::vector<token> error_format(const std::string& message)
|
||||
{
|
||||
return log_format("ERROR", message, color_codes::FG_RED);
|
||||
}
|
||||
|
||||
std::vector<token> verbose_format(const std::string& message)
|
||||
{
|
||||
return log_format("VERBOSE", message, color_codes::FG_CYAN);
|
||||
}
|
||||
|
||||
std::vector<token> debug_format(const std::string& message)
|
||||
{
|
||||
return log_format("DEBUG", message, color_codes::FG_GREEN);
|
||||
}
|
||||
|
||||
std::vector<token> debug_detailed_format(
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("DEBUG", message, func, file, line, color_codes::FG_GREEN);
|
||||
}
|
||||
|
||||
void direct(const std::string& message)
|
||||
{
|
||||
log({{.content = message, .delimiter = ""}});
|
||||
}
|
||||
|
||||
void info(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sinfo(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usinfo(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void verbose(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sverbose(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usverbose(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void debug(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sdebug(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usdebug(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void warning(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_YELLOW, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void swarning(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_YELLOW, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void uswarning(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_YELLOW, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void error(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void serror(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void userror(const std::string& message)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void fatal(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sfatal(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usfatal(const std::string& message)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
std::vector<token> info_detailed_format(
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("INFO", message, func, file, line);
|
||||
}
|
||||
|
||||
std::vector<token> warning_detailed_format(
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("WARNING", message, func, file, line, color_codes::FG_YELLOW);
|
||||
}
|
||||
|
||||
std::vector<token> error_detailed_format(
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("ERROR", message, func, file, line, color_codes::FG_RED);
|
||||
}
|
||||
|
||||
std::vector<token> fatal_format(const std::string& message)
|
||||
{
|
||||
return log_format("FATAL", message, color_codes::FG_BRIGHT_RED);
|
||||
}
|
||||
|
||||
std::vector<token> verbose_detailed_format(
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("VERBOSE", message, func, file, line, color_codes::FG_CYAN);
|
||||
}
|
||||
|
||||
std::vector<token> fatal_detailed_format(
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("FATAL", message, func, file, line, color_codes::FG_BRIGHT_RED);
|
||||
}
|
||||
|
||||
std::vector<token> log_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const colorcode& severity_cc)
|
||||
{
|
||||
auto severity = token{.colorCode = severity_cc, .content = severity_name};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
return {severity, content};
|
||||
}
|
||||
|
||||
std::vector<token> log_detailed_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line,
|
||||
const colorcode& severity_cc)
|
||||
{
|
||||
std::vector<token> tokens;
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto tf_tokens = jlog::trace_format(func, file, line);
|
||||
auto lf_tokens = jlog::log_format(severity_name, message, severity_cc);
|
||||
tokens.push_back(timestamp);
|
||||
tokens.insert(tokens.end(), tf_tokens.begin(), tf_tokens.end());
|
||||
tokens.insert(tokens.end(), lf_tokens.begin(), lf_tokens.end());
|
||||
return tokens;
|
||||
}
|
||||
|
||||
void info_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sinfo_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usinfo_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void verbose_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sverbose_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usverbose_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void debug_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sdebug_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usdebug_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void warning_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void swarning_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void uswarning_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void error_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void serror_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void userror_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void fatal_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sfatal_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usfatal_spec(const std::string& message, const std::string& func, const std::string& file, int line)
|
||||
{
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
}
|
@@ -1,432 +1,26 @@
|
||||
#include <jlog/jlog.hpp>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace jlog {
|
||||
std::string get_timestamp() {
|
||||
using namespace std::chrono;
|
||||
auto const timestamp = current_zone()->to_local(system_clock::now());
|
||||
auto dp = floor<days>(timestamp);
|
||||
year_month_day ymd{floor<days>(timestamp)};
|
||||
hh_mm_ss time{floor<milliseconds>(timestamp - dp)};
|
||||
auto y = ymd.year();
|
||||
auto m = ymd.month();
|
||||
auto d = ymd.day();
|
||||
auto h = time.hours();
|
||||
auto M = time.minutes();
|
||||
auto s = time.seconds();
|
||||
auto ms = time.subseconds();
|
||||
return std::format("{}-{}-{} {}:{}:{}.{}", y, m, d, h.count(), M.count(), s.count(), ms.count());
|
||||
}
|
||||
inline void SetConsoleTextColor(WORD color) {
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
|
||||
}
|
||||
|
||||
void log_to_console(const std::string& message) {
|
||||
std::cout << message;
|
||||
}
|
||||
|
||||
void log_to_file(const std::string& message) {
|
||||
std::ofstream latest_log("latest.log", std::ios_base::app);
|
||||
latest_log << message;
|
||||
latest_log.close();
|
||||
}
|
||||
|
||||
void log(std::vector<token> tokens) {
|
||||
namespace jlog
|
||||
{
|
||||
void log(const std::vector<token> tokens) {
|
||||
for (const token& t : tokens) {
|
||||
if (!t.delimiter.empty()) {
|
||||
nt_color_codes::SetConsoleTextColor(t.colorCode.nt_code);
|
||||
SetConsoleTextColor(t.colorCode.nt_code);
|
||||
log_to_console(std::string(1, t.delimiter[0]) + t.content + std::string(1, t.delimiter[1]) + " ");
|
||||
log_to_file(std::string(1, t.delimiter[0]) + t.content + std::string(1, t.delimiter[1]) + " ");
|
||||
} else {
|
||||
nt_color_codes::SetConsoleTextColor(t.colorCode.nt_code);
|
||||
SetConsoleTextColor(t.colorCode.nt_code);
|
||||
log_to_console(t.content + " ");
|
||||
log_to_file(t.content + " ");
|
||||
}
|
||||
}
|
||||
nt_color_codes::SetConsoleTextColor(color_codes::FG_DEFAULT.nt_code);
|
||||
SetConsoleTextColor(color_codes::FG_DEFAULT.nt_code);
|
||||
log_to_console("\n");
|
||||
log_to_file("\n");
|
||||
}
|
||||
|
||||
void direct(const std::string& message) {
|
||||
log({{.content = message, .delimiter = ""}});
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<token> trace_format(
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line)
|
||||
{
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
return {trace, filedata};
|
||||
}
|
||||
|
||||
std::vector<token> info_format(const std::string& message)
|
||||
{
|
||||
return log_format("INFO", message);
|
||||
}
|
||||
|
||||
std::vector<token> warning_format(const std::string& message)
|
||||
{
|
||||
return log_format("INFO", message, color_codes::FG_YELLOW);
|
||||
}
|
||||
|
||||
std::vector<token> error_format(const std::string& message)
|
||||
{
|
||||
return log_format("ERROR", message, color_codes::FG_RED);
|
||||
}
|
||||
|
||||
std::vector<token> verbose_format(const std::string& message)
|
||||
{
|
||||
return log_format("VERBOSE", message, color_codes::FG_CYAN);
|
||||
}
|
||||
|
||||
std::vector<token> debug_format(const std::string& message)
|
||||
{
|
||||
return log_format("DEBUG", message, color_codes::FG_GREEN);
|
||||
}
|
||||
|
||||
std::vector<token> debug_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("DEBUG", message, func, file, line, color_codes::FG_GREEN);
|
||||
}
|
||||
|
||||
void info(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sinfo(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usinfo(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void verbose(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sverbose(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usverbose(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void debug(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sdebug(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usdebug(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void warning(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_YELLOW, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void swarning(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_YELLOW, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void uswarning(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_YELLOW, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void error(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void serror(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void userror(const std::string& message) {
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void fatal(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({timestamp, severity, content});
|
||||
}
|
||||
|
||||
void sfatal(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void usfatal(const std::string& message) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
std::vector<token> info_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("INFO", message, func, file, line);
|
||||
}
|
||||
|
||||
std::vector<token> warning_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("WARNING", message, func, file, line, color_codes::FG_YELLOW);
|
||||
}
|
||||
|
||||
std::vector<token> error_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("ERROR", message, func, file, line, color_codes::FG_RED);
|
||||
}
|
||||
|
||||
std::vector<token> fatal_format(const std::string& message)
|
||||
{
|
||||
return log_format("FATAL", message, color_codes::FG_BRIGHT_RED);
|
||||
}
|
||||
|
||||
std::vector<token> verbose_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("VERBOSE", message, func, file, line, color_codes::FG_CYAN);
|
||||
}
|
||||
|
||||
std::vector<token> fatal_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line)
|
||||
{
|
||||
return log_detailed_format("FATAL", message, func, file, line, color_codes::FG_BRIGHT_RED);
|
||||
}
|
||||
|
||||
std::vector<token> log_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const colorcode& severity_cc)
|
||||
{
|
||||
auto severity = token{.colorCode = severity_cc, .content = severity_name};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
return {severity, content};
|
||||
}
|
||||
std::vector<token> log_detailed_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line,
|
||||
const colorcode& severity_cc)
|
||||
{
|
||||
std::vector<token> tokens;
|
||||
auto timestamp = token{.content = jlog::get_timestamp()};
|
||||
auto tf_tokens = trace_format(func, file, line);
|
||||
auto lf_tokens = log_format(severity_name, message, severity_cc);
|
||||
tokens.push_back(timestamp);
|
||||
tokens.insert(tokens.end(), tf_tokens.begin(), tf_tokens.end());
|
||||
tokens.insert(tokens.end(), lf_tokens.begin(), lf_tokens.end());
|
||||
return tokens;
|
||||
}
|
||||
|
||||
void info_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sinfo_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usinfo_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_WHITE, .content = "INFO"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void verbose_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sverbose_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usverbose_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_CYAN, .content = "VERBOSE"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void debug_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sdebug_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usdebug_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "DEBUG"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void warning_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void swarning_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void uswarning_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "WARNING"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void error_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_GREEN, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void serror_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void userror_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "ERROR"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
|
||||
void fatal_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({timestamp, trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void sfatal_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto timestamp = token{.content = get_timestamp()};
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
auto trace = token{.content = func};
|
||||
auto filedata = token{.content = std::format("{}:{}", file, line)};
|
||||
log({trace, filedata, severity, content});
|
||||
}
|
||||
|
||||
void usfatal_spec(const std::string& message, const std::string& func, const std::string& file, int line) {
|
||||
auto severity = token{.colorCode = color_codes::FG_BRIGHT_RED, .content = "FATAL"};
|
||||
auto content = token{.content = message, .delimiter = ""};
|
||||
log({severity, content});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user