85 return "\033[" + std::to_string(
static_cast<int>(code)) +
"m";
107 auto now = std::chrono::system_clock::now();
108 return std::format(
"{:%H:%M:%S}", now);
119 int emLevel = EM_LOG_CONSOLE;
122 emLevel = EM_LOG_CONSOLE;
125 emLevel = EM_LOG_CONSOLE;
128 emLevel = EM_LOG_WARN;
131 emLevel = EM_LOG_ERROR;
149 *
output << color << message << reset <<
"\n";
185 constexpr int bar_width = 20;
186 const int filled =
static_cast<int>(
progress *
static_cast<float>(bar_width));
190 bar.reserve(bar_width * 3);
191 for (
int i = 0; i < bar_width; ++i) {
192 bar += (i < filled) ?
"█" :
"░";
195 const std::string progress_message
196 = std::format(
"[{}] {:>3}% {}", bar,
static_cast<int>(
progress * 100.0f), message);
Structured logging system.
const char * level_to_string(asw::log::Level level)
AnsiCode level_to_ansi(asw::log::Level level)
AnsiCode
ANSI escape codes for terminal formatting.
asw::log::Level current_level
std::string get_timestamp()
std::string ansi_to_string(AnsiCode code)
void set_output(std::ostream &stream)
Set the output stream (default: std::cerr).
void info(const std::string &message)
Log an info message.
void debug(const std::string &message)
Log a debug message.
void log_message(Level level, const std::string &message)
Log a message at the specified level. Messages below the current log level are ignored.
void error(const std::string &message)
Log an error message.
void warn(const std::string &message)
Log a warning message.
Level
Log severity levels.
void progress(float progress, std::string message)
Log a progress message with a percentage.
void set_level(Level level)
Set the minimum log level (messages below this are ignored).