refactor: rename LOG_HIGHLIGHT_ESCAPE to LOG_HIGHLIGHT_COLOR

- More intuitive naming for users
- Changed get_log_highlight_escape() to get_log_highlight_color()
- Updated all references and comments
- Functionality remains the same, just clearer naming
This commit is contained in:
Nicholas Dudfield
2025-07-26 17:02:08 +07:00
parent ae019a979c
commit e0cc2b8b1e
3 changed files with 9 additions and 9 deletions

View File

@@ -354,7 +354,7 @@ Logs::format(
if (!partition.empty())
{
#ifdef BEAST_ENHANCED_LOGGING
output += beast::detail::get_log_highlight_escape();
output += beast::detail::get_log_highlight_color();
#endif
output += partition + ":";
}

View File

@@ -30,10 +30,10 @@ namespace detail {
bool
should_log_use_colors();
// Get the log location escape sequence - can be overridden via
// LOG_LOCATION_ESCAPE
// Get the log highlight color - can be overridden via
// LOG_HIGHLIGHT_COLOR
const char*
get_log_highlight_escape();
get_log_highlight_color();
// Strip source root path from __FILE__ at compile time
// IMPORTANT: This MUST stay in the header as constexpr for compile-time

View File

@@ -45,13 +45,13 @@ should_log_use_colors()
return use_colors;
}
// Get the log location escape sequence - can be overridden via
// LOG_LOCATION_ESCAPE
// Get the log highlight color - can be overridden via
// LOG_HIGHLIGHT_COLOR
const char*
get_log_highlight_escape()
get_log_highlight_color()
{
static const char* escape = []() {
const char* env = std::getenv("LOG_HIGHLIGHT_ESCAPE");
const char* env = std::getenv("LOG_HIGHLIGHT_COLOR");
if (!env)
return "\033[36m"; // Default: cyan
@@ -111,7 +111,7 @@ log_write_location_string(std::ostream& os, const char* file, int line)
{
if (detail::should_log_use_colors())
{
os << detail::get_log_highlight_escape() << "["
os << detail::get_log_highlight_color() << "["
<< detail::strip_source_root(file) << ":" << line << "]\033[0m";
}
else