Removed need for jlog to handle colors. Using mcolor library now.
This commit is contained in:
@@ -1,108 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
|
||||
namespace jlog::ansi_escape_codes
|
||||
{
|
||||
inline static const std::string CURSOR_HOME = "\033[H";
|
||||
|
||||
inline static const std::string ERASE_SCREEN_AFTER_CURSOR = "\033[0J";
|
||||
inline static const std::string ERASE_SCREEN_BEFORE_CURSOR = "\033[1J";
|
||||
inline static const std::string ERASE_SCREEN_ALL = "\033[2J";
|
||||
inline static const std::string ERASE_LINE_AFTER_CURSOR = "\033[0K";
|
||||
inline static const std::string ERASE_LINE_BEFORE_CURSOR = "\033[1K";
|
||||
inline static const std::string ERASE_LINE_ALL = "\033[2K";
|
||||
|
||||
inline static const std::string RESET = "\033[0m";
|
||||
inline static const std::string BOLD = "\033[1m";
|
||||
inline static const std::string DIM = "\033[2m";
|
||||
|
||||
/// These are some examples of private modes, which are not defined by the spec, but are implemented in most terminals.
|
||||
/// @see xterm control sequences for a more in-depth list.
|
||||
/// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||
/// @note While these modes may be supported by most terminals, some may not work in multiplexers like tmux.
|
||||
|
||||
inline static const std::string CURSOR_INVISIBLE = "\033[?25l";
|
||||
inline static const std::string CURSOR_VISIBLE = "\033[?25h";
|
||||
inline static const std::string RESTORE_SCREEN = "\033[?47l";
|
||||
inline static const std::string SAVE_SCREEN = "\033[?47h";
|
||||
|
||||
|
||||
inline static const std::string FG_BLACK = "\033[30m";
|
||||
inline static const std::string FG_RED = "\033[31m";
|
||||
inline static const std::string FG_GREEN = "\033[32m";
|
||||
inline static const std::string FG_YELLOW = "\033[33m";
|
||||
inline static const std::string FG_BLUE = "\033[34m";
|
||||
inline static const std::string FG_MAGENTA = "\033[35m";
|
||||
inline static const std::string FG_CYAN = "\033[36m";
|
||||
inline static const std::string FG_WHITE = "\033[37m";
|
||||
inline static const std::string FG_DEFAULT = "\033[39m";
|
||||
|
||||
|
||||
inline static const std::string FG_BRIGHT_BLACK = "\033[90m";
|
||||
inline static const std::string FG_BRIGHT_RED = "\033[91m";
|
||||
inline static const std::string FG_BRIGHT_GREEN = "\033[92m";
|
||||
inline static const std::string FG_BRIGHT_YELLOW = "\033[93m";
|
||||
inline static const std::string FG_BRIGHT_BLUE = "\033[94m";
|
||||
inline static const std::string FG_BRIGHT_MAGENTA = "\033[95m";
|
||||
inline static const std::string FG_BRIGHT_CYAN = "\033[96m";
|
||||
inline static const std::string FG_BRIGHT_WHITE = "\033[97m";
|
||||
|
||||
|
||||
inline static const std::string BG_BLACK = "\033[40m";
|
||||
inline static const std::string BG_RED = "\033[41m";
|
||||
inline static const std::string BG_GREEN = "\033[42m";
|
||||
inline static const std::string BG_YELLOW = "\033[43m";
|
||||
inline static const std::string BG_BLUE = "\033[44m";
|
||||
inline static const std::string BG_MAGENTA = "\033[45m";
|
||||
inline static const std::string BG_CYAN = "\033[46m";
|
||||
inline static const std::string BG_WHITE = "\033[47m";
|
||||
inline static const std::string BG_DEFAULT = "\033[49m";
|
||||
|
||||
inline static const std::string BG_BRIGHT_BLACK = "\033[100m";
|
||||
inline static const std::string BG_BRIGHT_RED = "\033[101m";
|
||||
inline static const std::string BG_BRIGHT_GREEN = "\033[102m";
|
||||
inline static const std::string BG_BRIGHT_YELLOW = "\033[103m";
|
||||
inline static const std::string BG_BRIGHT_BLUE = "\033[104m";
|
||||
inline static const std::string BG_BRIGHT_MAGENTA = "\033[105m";
|
||||
inline static const std::string BG_BRIGHT_CYAN = "\033[106m";
|
||||
inline static const std::string BG_BRIGHT_WHITE = "\033[107m";
|
||||
|
||||
inline std::string true_color(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
return std::format("\033[38;2;{};{};{}m", r, g, b);
|
||||
}
|
||||
|
||||
inline std::string cursor_to(int line, int col)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
inline std::string cursor_up(int lines)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
inline std::string cursor_down(int lines)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
inline std::string cursor_left(int cols)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
inline std::string cursor_right(int cols)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
inline std::string cursor_to_col(int col)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <jlog/ansi_escape_codes.hpp>
|
||||
|
||||
// Platform independent color code mapping
|
||||
|
||||
struct colorcode
|
||||
{
|
||||
std::string ansi_code;
|
||||
};
|
||||
|
||||
namespace jlog::color_codes
|
||||
{
|
||||
static const colorcode FG_BLACK {ansi_escape_codes::FG_BLACK};
|
||||
static const colorcode FG_RED {ansi_escape_codes::FG_RED};
|
||||
static const colorcode FG_GREEN {ansi_escape_codes::FG_GREEN };
|
||||
static const colorcode FG_YELLOW {ansi_escape_codes::FG_YELLOW};
|
||||
static const colorcode FG_BLUE {ansi_escape_codes::FG_BLUE};
|
||||
static const colorcode FG_MAGENTA {ansi_escape_codes::FG_MAGENTA};
|
||||
static const colorcode FG_CYAN {ansi_escape_codes::FG_CYAN};
|
||||
static const colorcode FG_WHITE {ansi_escape_codes::FG_WHITE};
|
||||
static const colorcode FG_DEFAULT {ansi_escape_codes::FG_DEFAULT};
|
||||
|
||||
static const colorcode FG_BRIGHT_BLACK {ansi_escape_codes::FG_BRIGHT_BLACK};
|
||||
static const colorcode FG_BRIGHT_RED {ansi_escape_codes::FG_BRIGHT_RED};
|
||||
static const colorcode FG_BRIGHT_GREEN {ansi_escape_codes::FG_BRIGHT_GREEN};
|
||||
static const colorcode FG_BRIGHT_YELLOW {ansi_escape_codes::FG_BRIGHT_YELLOW};
|
||||
static const colorcode FG_BRIGHT_BLUE {ansi_escape_codes::FG_BRIGHT_MAGENTA};
|
||||
static const colorcode FG_BRIGHT_MAGENTA {ansi_escape_codes::FG_BRIGHT_MAGENTA};
|
||||
static const colorcode FG_BRIGHT_CYAN {ansi_escape_codes::FG_BRIGHT_CYAN};
|
||||
static const colorcode FG_BRIGHT_WHITE {ansi_escape_codes::FG_BRIGHT_WHITE};
|
||||
|
||||
static const colorcode BG_BLACK {ansi_escape_codes::BG_BLACK};
|
||||
static const colorcode BG_RED {ansi_escape_codes::BG_RED};
|
||||
static const colorcode BG_GREEN {ansi_escape_codes::BG_GREEN};
|
||||
static const colorcode BG_YELLOW {ansi_escape_codes::BG_YELLOW};
|
||||
static const colorcode BG_BLUE {ansi_escape_codes::BG_BLUE};
|
||||
static const colorcode BG_MAGENTA {ansi_escape_codes::BG_MAGENTA};
|
||||
static const colorcode BG_CYAN {ansi_escape_codes::BG_CYAN};
|
||||
static const colorcode BG_WHITE {ansi_escape_codes::BG_WHITE};
|
||||
static const colorcode BG_DEFAULT {ansi_escape_codes::BG_DEFAULT};
|
||||
|
||||
static const colorcode BG_BRIGHT_BLACK {ansi_escape_codes::BG_BRIGHT_BLACK};
|
||||
static const colorcode BG_BRIGHT_RED {ansi_escape_codes::BG_BRIGHT_RED};
|
||||
static const colorcode BG_BRIGHT_GREEN {ansi_escape_codes::BG_BRIGHT_GREEN};
|
||||
static const colorcode BG_BRIGHT_YELLOW {ansi_escape_codes::BG_BRIGHT_YELLOW};
|
||||
static const colorcode BG_BRIGHT_BLUE {ansi_escape_codes::BG_BRIGHT_BLUE};
|
||||
static const colorcode BG_BRIGHT_MAGENTA {ansi_escape_codes::BG_BRIGHT_MAGENTA};
|
||||
static const colorcode BG_BRIGHT_CYAN {ansi_escape_codes::BG_BRIGHT_CYAN};
|
||||
static const colorcode BG_BRIGHT_WHITE {ansi_escape_codes::BG_BRIGHT_WHITE};
|
||||
}
|
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <Event.h>
|
||||
#include <jlog/color_codes.hpp>
|
||||
#include <mcolor.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#define FUNCTION __PRETTY_FUNCTION__
|
||||
@@ -51,7 +51,7 @@ namespace jlog
|
||||
/// These are strung together to build full logger messages in a flexible manner.
|
||||
struct token
|
||||
{
|
||||
colorcode colorCode = color_codes::FG_DEFAULT;
|
||||
mcolor::ansiColors::Colors colorCode = mcolor::ansiColors::Colors::FG_DEFAULT;
|
||||
std::string content = "";
|
||||
std::string delimiter = "[]";
|
||||
};
|
||||
@@ -108,11 +108,11 @@ namespace jlog
|
||||
/// Returns a formatted sequence of tokens given a severity and message.
|
||||
/// @param severity_name The severity tag to prefix to the message. Could theoretically also be a context.
|
||||
/// @param message The actual message to include
|
||||
/// @param severity_cc The colorcode to assign to the severity. See color_codes.hpp
|
||||
/// @param severity_cc The colorcode to assign to the severity.
|
||||
std::vector<token> log_format(
|
||||
const std::string& severity_name,
|
||||
const std::string& message,
|
||||
const colorcode& severity_cc = color_codes::FG_WHITE);
|
||||
const mcolor::ansiColors::Colors& severity_cc = mcolor::ansiColors::Colors::FG_WHITE);
|
||||
|
||||
/// Returns a more detailed formatted sequence of tokens.
|
||||
/// @param severity_name The severity tag to prefix to the message. Could theoretically also be a context.
|
||||
@@ -120,14 +120,14 @@ namespace jlog
|
||||
/// @param func The function name/signature to trace back to. Should be provided by a __FUNCTION__ macro variant.
|
||||
/// @param file The file name to trace back to. Should be provided by a __FILE__ macro variant.
|
||||
/// @param line The source-code line to trace back to. Should be provided by a __LINE__ macro variant.
|
||||
/// @param severity_cc The colorcode to assign to the severity. See color_codes.hpp
|
||||
/// @param severity_cc The colorcode to assign to the severity.
|
||||
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 = color_codes::FG_WHITE);
|
||||
const mcolor::ansiColors::Colors& severity_cc = mcolor::ansiColors::Colors::FG_WHITE);
|
||||
|
||||
/// Returns a token sequence pre-formatted for the INFO log level.
|
||||
/// @param message The message to send out.
|
||||
|
Reference in New Issue
Block a user