1#ifndef __COMMON_LOGGER_HPP__
2#define __COMMON_LOGGER_HPP__
4#include <source_location>
13 constexpr auto blue =
"\033[34m";
14 constexpr auto red =
"\033[31m";
15 constexpr auto reset =
"\033[0m";
16 constexpr auto green =
"\033[32m";
46 virtual void debug(std::string_view message) = 0;
57 virtual void print(std::string_view prefix, std::string_view message) = 0;
67 virtual void alert(std::string_view prefix, std::string_view message) = 0;
79 virtual void error(std::string_view message,
80 std::source_location location
81 = std::source_location::current())
91 virtual void raw_log(std::string_view message) = 0;
139 template <typename MsgType>
140 requires(std::is_integral_v<std::remove_cvref_t<MsgType>>
141 || std::is_floating_point_v<std::remove_cvref_t<MsgType>>)
145 result += std::to_string(std::forward<MsgType>(msg));
148 template <
typename MsgType>
149 requires(!(std::is_integral_v<std::remove_cvref_t<MsgType>>
150 || std::is_floating_point_v<std::remove_cvref_t<MsgType>>))
155 result += std::forward<MsgType>(msg);
158 template <
typename... MsgType>
163 (
_format(result, std::forward<MsgType>(msgs)), ...);
virtual void error(std::string_view message, std::source_location location=std::source_location::current())=0
Log an error message with optional location details.
Logger & operator=(const Logger &)=default
virtual void toggle_alert() noexcept=0
Toggle the alert logging behavior on or off.
virtual void toggle_debug() noexcept=0
Toggle the debug logging behavior on or off.
virtual void toggle_error() noexcept=0
Toggle the error logging behavior on or off.
virtual void raw_log(std::string_view message)=0
Log a raw message with no additional formatting.
virtual void debug(std::string_view message)=0
Log a debug message.
Logger(const Logger &)=default
virtual ~Logger()=default
virtual void alert(std::string_view prefix, std::string_view message)=0
Log an alert message with a prefix.
Logger & operator=(Logger &&)=default
virtual void print(std::string_view prefix, std::string_view message)=0
Log a regular print message with a prefix.
virtual void toggle_print() noexcept=0
Toggle the print logging behavior on or off.
virtual void toggle_all() noexcept=0
Toggle all logging types on or off.
Logger(Logger &&)=default
constexpr auto red
Definition logger.hpp:14
constexpr auto green
Definition logger.hpp:16
constexpr auto reset
Definition logger.hpp:15
constexpr auto blue
Definition logger.hpp:13
constexpr auto red_circle
Definition logger.hpp:21
Definition impl_post_process.hpp:11
std::string format(MsgType &&... msgs)
Definition logger.hpp:160
void _format(std::string &result, MsgType &&msg)
Definition logger.hpp:143