File output.h
File List > casvp > src > utils > output.h
Go to the documentation of this file
#pragma once
#include <fmt/color.h>
#include <fmt/core.h>
#include <fmt/ranges.h>
namespace {
struct fatal_error : virtual std::exception {};
template <typename T>
inline void Output(T &&severity, fmt::string_view fmt, fmt::format_args args) {
fmt::print("{} {}", std::forward<T>(severity), fmt::vformat(fmt, args));
}
} // namespace
template <typename... T>
inline void Fatal(fmt::format_string<T...> fmt, T &&...args) {
Output(fmt::styled("Fatal:", fmt::fg(fmt::color::red)), fmt,
fmt::make_format_args(args...));
throw fatal_error();
}
template <typename... T>
inline void Warning(fmt::format_string<T...> fmt, T &&...args) {
Output(fmt::styled("Warning:", fmt::fg(fmt::color::orange)), fmt,
fmt::make_format_args(args...));
}
template <typename... T>
inline void Info(fmt::format_string<T...> fmt, T &&...args) {
Output(fmt::styled("Info:", fmt::fg(fmt::color::light_blue)), fmt,
fmt::make_format_args(args...));
}