8#include <unordered_map>
10#define FMT_HEADER_ONLY
11#include <fmt/format.h>
12#include <fmt/ranges.h>
14#include "vipra/macros/performance.hpp"
27 static void set_level(Level lvl) { level = lvl; }
28 static void set_level(std::string lvl)
30 static const std::unordered_map<std::string, Level> LEVELS = {
31 {
"debug", Level::DEBUG},
32 {
"info", Level::INFO},
33 {
"warn", Level::WARN},
34 {
"error", Level::ERROR},
37 std::transform(lvl.begin(), lvl.end(), lvl.begin(),
38 [](
char letter) { return tolower(letter); });
40 level = LEVELS.at(lvl);
50 template <
typename... param_ts>
51 VIPRA_INLINE
static void warn(fmt::format_string<param_ts...> message,
54 if ( level <= Level::WARN ) {
55 std::cout <<
"[WARN] " << fmt::format(message, std::forward<param_ts>(params)...)
67 template <
typename... param_ts>
68 VIPRA_INLINE
static void info(fmt::format_string<param_ts...> message,
71 if ( level <= Level::INFO ) {
72 std::cout <<
"[INFO] " << fmt::format(message, std::forward<param_ts>(params)...)
84 template <
typename... param_ts>
85 VIPRA_INLINE
static void debug(fmt::format_string<param_ts...> message,
88 if ( level <= Level::DEBUG ) {
89 std::cout <<
"[DEBUG] " << fmt::format(message, std::forward<param_ts>(params)...)
101 template <
typename... param_ts>
102 VIPRA_INLINE
static void error(fmt::format_string<param_ts...> message,
103 param_ts&&... params)
105 std::cout <<
"[ERROR] " << fmt::format(message, std::forward<param_ts>(params)...)
Definition logging.hpp:18
static VIPRA_INLINE void error(fmt::format_string< param_ts... > message, param_ts &&... params)
Calls the provided Logger with Level DEBUG.
Definition logging.hpp:102
static VIPRA_INLINE void warn(fmt::format_string< param_ts... > message, param_ts &&... params)
Calls the provided Logger with Level WARN.
Definition logging.hpp:51
static VIPRA_INLINE void debug(fmt::format_string< param_ts... > message, param_ts &&... params)
Calls the provided Logger with Level DEBUG.
Definition logging.hpp:85
static VIPRA_INLINE void info(fmt::format_string< param_ts... > message, param_ts &&... params)
Calls the provided Logger with Level INFO.
Definition logging.hpp:68