diff --git a/include/jlog/jlog.hpp b/include/jlog/jlog.hpp index eada308..66807fe 100644 --- a/include/jlog/jlog.hpp +++ b/include/jlog/jlog.hpp @@ -48,29 +48,92 @@ namespace jlog void log(std::vector tokens); void info (const std::string& message); + void sinfo (const std::string& message); + void usinfo (const std::string& message); + + void verbose(const std::string& message); + void sverbose(const std::string& message); + void usverbose(const std::string& message); + void debug (const std::string& message); + void sdebug (const std::string& message); + void usdebug (const std::string& message); + void warning(const std::string& message); + void swarning(const std::string& message); + void uswarning(const std::string& message); + void error (const std::string& message); + void serror (const std::string& message); + void userror (const std::string& message); + void fatal (const std::string& message); + void sfatal (const std::string& message); + void usfatal (const std::string& message); void info_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void sinfo_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void usinfo_spec(const std::string& message, const std::string& func, const std::string& file, int line); + + void verbose_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void sverbose_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void usverbose_spec(const std::string& message, const std::string& func, const std::string& file, int line); + + void debug_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void sdebug_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void usdebug_spec(const std::string& message, const std::string& func, const std::string& file, int line); + + void warning_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void swarning_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void uswarning_spec(const std::string& message, const std::string& func, const std::string& file, int line); + + void error_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void serror_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void userror_spec(const std::string& message, const std::string& func, const std::string& file, int line); + + void fatal_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void sfatal_spec(const std::string& message, const std::string& func, const std::string& file, int line); + void usfatal_spec(const std::string& message, const std::string& func, const std::string& file, int line); + } #define INFO(i) jlog::info_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define SINFO(i) jlog::sinfo_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define USINFO(i) jlog::usinfo_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); + + #define VERBOSE(i) jlog::verbose_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define SVERBOSE(i) jlog::sverbose_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define USVERBOSE(i) jlog::usverbose_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); + + #define DEBUG(i) jlog::debug_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define SDEBUG(i) jlog::sdebug_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define USDEBUG(i) jlog::usdebug_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); + + #define WARNING(i) jlog::warning_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define SWARNING(i) jlog::swarning_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define USWARNING(i) jlog::uswarning_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); + + #define ERROR(i) jlog::error_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define SERROR(i) jlog::serror_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define USERROR(i) jlog::userror_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); + + #define FATAL(i) jlog::fatal_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define SFATAL(i) jlog::sfatal_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); +#define USFATAL(i) jlog::usfatal_spec(i, __PRETTY_FUNCTION__, __FILE__, __LINE__); \ No newline at end of file diff --git a/main.cpp b/main.cpp index b8ab481..e74e5eb 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,21 @@ int main() WARNING("Slight miscalculation!"); ERROR("Oops, something went wrong."); FATAL("Unrecoverable Error!!!"); + + SINFO("This is even less useful information."); + SDEBUG("Shorter Debugging Information"); + SVERBOSE("Yadda Yadda"); + SWARNING("Minute miscalculation!"); + SERROR("Oops, something went wrong, but the programmer used the short error logger so you're fucked!"); + SFATAL("Unrecoverable Error, but the programmer used the short fatal logger so you're even more fucked!!!"); + + USINFO("This is EVEN less useful information."); + USDEBUG("Ultra compact debugging information."); + USVERBOSE("Isn't this an oxymoron?"); + USWARNING("Captain Quark grade miscalculation!"); + USERROR("You're fucked!"); + USFATAL("You're super fucked!!!"); + return 0; /// } \ No newline at end of file diff --git a/src/jlog/jlog.cpp b/src/jlog/jlog.cpp index c488d46..3da8eb6 100644 --- a/src/jlog/jlog.cpp +++ b/src/jlog/jlog.cpp @@ -62,6 +62,21 @@ namespace jlog { log({timestamp, severity, content}); } + void sinfo(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_WHITE, .content = "INFO"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + } + void usinfo(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_WHITE, .content = "INFO"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + } + void verbose(const std::string &message) { auto timestamp = token{.content = get_timestamp()}; auto severity = token{.colorCode = ansi_escape_codes::FG_CYAN, .content = "VERBOSE"}; @@ -71,6 +86,24 @@ namespace jlog { //log(ansi_escape_codes::FG_CYAN, "VERBOSE", message); } + void sverbose(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_CYAN, .content = "VERBOSE"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + //log(ansi_escape_codes::FG_CYAN, "VERBOSE", message); + } + + void usverbose(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_CYAN, .content = "VERBOSE"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + //log(ansi_escape_codes::FG_CYAN, "VERBOSE", message); + } + void debug(const std::string &message) { auto timestamp = token{.content = get_timestamp()}; auto severity = token{.colorCode = ansi_escape_codes::FG_GREEN, .content = "DEBUG"}; @@ -80,6 +113,22 @@ namespace jlog { } + void sdebug(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_GREEN, .content = "DEBUG"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + } + + void usdebug(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_GREEN, .content = "DEBUG"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + } + void warning(const std::string &message) { auto timestamp = token{.content = get_timestamp()}; auto severity = token{.colorCode = ansi_escape_codes::FG_YELLOW, .content = "WARNING"}; @@ -89,6 +138,15 @@ namespace jlog { //log(ansi_escape_codes::FG_YELLOW, "WARNING", message); } + void uswarning(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_YELLOW, .content = "WARNING"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + //log(ansi_escape_codes::FG_YELLOW, "WARNING", message); + } + void error(const std::string &message) { auto timestamp = token{.content = get_timestamp()}; auto severity = token{.colorCode = ansi_escape_codes::FG_RED, .content = "ERROR"}; @@ -98,6 +156,15 @@ namespace jlog { //log(ansi_escape_codes::FG_RED, "ERROR", message); } + void userror(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_RED, .content = "ERROR"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = }; + log({severity, content}); + //log(ansi_escape_codes::FG_RED, "ERROR", message); + } + void fatal(const std::string &message) { auto timestamp = token{.content = get_timestamp()}; auto severity = token{.colorCode = ansi_escape_codes::FG_BRIGHT_RED, .content = "FATAL"}; @@ -106,6 +173,14 @@ namespace jlog { log({timestamp, severity, content}); } + void usfatal(const std::string &message) { + //auto timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_BRIGHT_RED, .content = "FATAL"}; + auto content = token{.content = message, .delimiter = ""}; + + log({severity, content}); + } + void info_spec(const std::string &message, const std::string &func, const std::string &file, int line) { auto timestamp = token{.content = get_timestamp()}; @@ -116,6 +191,28 @@ namespace jlog { log({timestamp, trace, filedata, severity, content}); } + void sinfo_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 = ansi_escape_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}); + //log({severity, content}); + } + + void usinfo_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 = ansi_escape_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}); + 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()}; @@ -126,6 +223,26 @@ namespace jlog { log({timestamp, trace, filedata, severity, content}); } + void sverbose_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 = ansi_escape_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 timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_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({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()}; @@ -136,6 +253,26 @@ namespace jlog { log({timestamp, trace, filedata, severity, content}); } + void sdebug_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 = ansi_escape_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 timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_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({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()}; @@ -146,6 +283,26 @@ namespace jlog { log({timestamp, trace, filedata, severity, content}); } + void swarning_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 = ansi_escape_codes::FG_YELLOW, .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 timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_codes::FG_YELLOW, .content = "WARNING"}; + auto content = token{.content = message, .delimiter = ""}; + //auto trace = token{.content = func}; + //auto filedata = token{.content = std::format("{}:{}", file, line)}; + 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()}; @@ -156,6 +313,26 @@ namespace jlog { log({timestamp, trace, filedata, severity, content}); } + void serror_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 = ansi_escape_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 timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_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({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()}; @@ -165,4 +342,24 @@ namespace jlog { 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 = ansi_escape_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 timestamp = token{.content = get_timestamp()}; + auto severity = token{.colorCode = ansi_escape_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({severity, content}); + } }