nestlog: + terminal colors for entry/exit/code location

This commit is contained in:
Roland Conybeare 2023-09-15 13:24:02 -04:00
commit fd2be2a4ae
6 changed files with 265 additions and 12 deletions

View file

@ -3,6 +3,7 @@
#pragma once
#include "function.hpp"
#include "nestlog/color.hpp"
#include <cstdint>
namespace xo {
@ -13,10 +14,19 @@ namespace xo {
static std::uint32_t indent_width;
/* display style for function names. FS_Simple|FS_Pretty|FS_Streamlined */
static function_style style;
/* color encoding */
static color_encoding encoding;
/* color to use for function name, on entry/exit (xo::scope creation/destruction)
* (ansi color codes, see Select Graphics Rendition subset)
*/
static std::uint32_t function_entry_color;
static std::uint32_t function_exit_color;
/* if true, append [file:line] to output */
static bool location_enabled;
/* when .location_enabled, write [file:line] starting this many chars from left margin */
static std::uint32_t location_tab;
/* color to use for code location */
static std::uint32_t code_location_color;
}; /*log_config_impl*/
template <typename Tag>
@ -27,6 +37,18 @@ namespace xo {
function_style
log_config_impl<Tag>::style = FS_Streamlined;
template <typename Tag>
color_encoding
log_config_impl<Tag>::encoding = CE_Ansi;
template <typename Tag>
std::uint32_t
log_config_impl<Tag>::function_entry_color = 34;
template <typename Tag>
std::uint32_t
log_config_impl<Tag>::function_exit_color = 32;
template <typename Tag>
bool
log_config_impl<Tag>::location_enabled = true;
@ -35,6 +57,10 @@ namespace xo {
std::uint32_t
log_config_impl<Tag>::location_tab = 80;
template <typename Tag>
std::uint32_t
log_config_impl<Tag>::code_location_color = 31;
using log_config = log_config_impl<class log_config_tag>;
} /*namespace xo*/