Rewritten most functionality to be more generic and flexible. Cleaned up code as well. Implemented formatter system for easier wrapping. Made it easier for custom loggers to be built from jlog generics and primitives. Removed unused ultra short and short loggers to remove clutter.
This commit is contained in:
@@ -25,17 +25,6 @@
|
||||
|
||||
namespace jlog
|
||||
{
|
||||
/*enum class severity : uint8_t
|
||||
{
|
||||
none,
|
||||
verbose,
|
||||
debug,
|
||||
warning,
|
||||
error,
|
||||
fatal
|
||||
};
|
||||
*/
|
||||
|
||||
enum class severity : uint8_t
|
||||
{
|
||||
none,
|
||||
@@ -76,79 +65,85 @@ namespace jlog
|
||||
|
||||
void log(std::vector<token> tokens);
|
||||
|
||||
void info(const std::string& message);
|
||||
void sinfo(const std::string& message);
|
||||
void usinfo(const std::string& message);
|
||||
// Generic formatters for building loggers.
|
||||
std::vector<token> trace_format(
|
||||
const std::string& func,
|
||||
const std::string& file,
|
||||
int line);
|
||||
|
||||
void verbose(const std::string& message);
|
||||
void sverbose(const std::string& message);
|
||||
void usverbose(const std::string& message);
|
||||
std::vector<token> log_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const std::string& severity_colorCode = ansi_escape_codes::FG_WHITE);
|
||||
|
||||
void debug(const std::string& message);
|
||||
void sdebug(const std::string& message);
|
||||
void usdebug(const std::string& message);
|
||||
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 std::string& severity_colorCode = ansi_escape_codes::FG_WHITE);
|
||||
|
||||
void warning(const std::string& message);
|
||||
void swarning(const std::string& message);
|
||||
void uswarning(const std::string& message);
|
||||
// Predefined generic loggers for jlog.
|
||||
std::vector<token> info_format(const std::string& message);
|
||||
|
||||
void error(const std::string& message);
|
||||
void serror(const std::string& message);
|
||||
void userror(const std::string& message);
|
||||
std::vector<token> info_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line);
|
||||
|
||||
void fatal(const std::string& message);
|
||||
void sfatal(const std::string& message);
|
||||
void usfatal(const std::string& message);
|
||||
std::vector<token> warning_format(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);
|
||||
std::vector<token> warning_detailed_format(
|
||||
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);
|
||||
std::vector<token> error_format(const std::string& message);
|
||||
|
||||
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);
|
||||
std::vector<token> error_detailed_format(
|
||||
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);
|
||||
std::vector<token> fatal_format(const std::string& message);
|
||||
|
||||
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);
|
||||
std::vector<token> fatal_detailed_format(
|
||||
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);
|
||||
std::vector<token> verbose_format(const std::string& message);
|
||||
|
||||
std::vector<token> verbose_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line);
|
||||
|
||||
std::vector<token> debug_format(const std::string& message);
|
||||
|
||||
std::vector<token> debug_detailed_format(
|
||||
const std::string &message,
|
||||
const std::string &func,
|
||||
const std::string &file,
|
||||
int line);
|
||||
}
|
||||
|
||||
#define INFO(i) if (jlog::loglevel >= jlog::severity::none) { jlog::info_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define SINFO(i) if (jlog::loglevel >= jlog::severity::none) { jlog::sinfo_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define USINFO(i) if (jlog::loglevel >= jlog::severity::none) { jlog::usinfo_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define INFO(i) if (jlog::loglevel >= jlog::severity::none) { jlog::log(jlog::info_detailed_format(i, FUNCTION, __FILE__, __LINE__)); };
|
||||
|
||||
#define VERBOSE(i) if (jlog::loglevel >= jlog::severity::verbose) { jlog::verbose_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define SVERBOSE(i) if (jlog::loglevel >= jlog::severity::verbose) { jlog::sverbose_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define USVERBOSE(i) if (jlog::loglevel >= jlog::severity::verbose) { jlog::usverbose_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define VERBOSE(i) if (jlog::loglevel >= jlog::severity::verbose) { jlog::log(jlog::verbose_detailed_format(i, FUNCTION, __FILE__, __LINE__)); };
|
||||
|
||||
#define DEBUG(i) if (jlog::loglevel >= jlog::severity::debug) { jlog::debug_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define SDEBUG(i) if (jlog::loglevel >= jlog::severity::debug) { jlog::sdebug_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define USDEBUG(i) if (jlog::loglevel >= jlog::severity::debug) { jlog::usdebug_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define DEBUG(i) if (jlog::loglevel >= jlog::severity::debug) { jlog::log(jlog::debug_detailed_format(i, FUNCTION, __FILE__, __LINE__)); };
|
||||
|
||||
#define WARNING(i) if (jlog::loglevel >= jlog::severity::warning) { jlog::warning_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define SWARNING(i) if (jlog::loglevel >= jlog::severity::warning) { jlog::swarning_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define USWARNING(i) if (jlog::loglevel >= jlog::severity::warning) { jlog::uswarning_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define WARNING(i) if (jlog::loglevel >= jlog::severity::warning) { jlog::log(jlog::warning_detailed_format(i, FUNCTION, __FILE__, __LINE__)); };
|
||||
|
||||
#define ERROR(i) if (jlog::loglevel >= jlog::severity::error) { jlog::error_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define SERROR(i) if (jlog::loglevel >= jlog::severity::error) { jlog::serror_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define USERROR(i) if (jlog::loglevel >= jlog::severity::error) { jlog::userror_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define ERROR(i) if (jlog::loglevel >= jlog::severity::error) { jlog::log(jlog::error_detailed_format(i, FUNCTION, __FILE__, __LINE__)); };
|
||||
|
||||
#define FATAL(i) if (jlog::loglevel >= jlog::severity::fatal) { jlog::fatal_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define SFATAL(i) if (jlog::loglevel >= jlog::severity::fatal) { jlog::sfatal_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
#define USFATAL(i) if (jlog::loglevel >= jlog::severity::fatal) { jlog::usfatal_spec(i, FUNCTION, __FILE__, __LINE__); };
|
||||
|
||||
//LINFO
|
||||
#define FATAL(i) if (jlog::loglevel >= jlog::severity::fatal) { jlog::log(jlog::fatal_detailed_format(i, FUNCTION, __FILE__, __LINE__)); };
|
||||
|
||||
#define LOGLEVEL(i) jlog::loglevel = i;
|
Reference in New Issue
Block a user