22#include "util/SourceLocation.hpp"
23#include "util/log/Logger.hpp"
25#include <boost/log/core/core.hpp>
26#ifndef CLIO_WITHOUT_STACKTRACE
27#include <boost/stacktrace.hpp>
28#include <boost/stacktrace/stacktrace.hpp>
31#include <fmt/format.h>
49template <
typename... Args>
53 char const* expression,
55 fmt::format_string<Args...> format,
60#ifndef CLIO_WITHOUT_STACKTRACE
61 auto const resultMessage = fmt::format(
62 "Assertion '{}' failed at {}:{}:\n{}\nStacktrace:\n{}",
66 fmt::format(format, std::forward<Args>(args)...),
67 boost::stacktrace::to_string(boost::stacktrace::stacktrace())
70 auto const resultMessage = fmt::format(
71 "Assertion '{}' failed at {}:{}:\n{}",
75 fmt::format(format, std::forward<Args>(args)...)
78 if (boost::log::core::get()->get_logging_enabled()) {
81 std::cerr << resultMessage;
83 std::exit(EXIT_FAILURE);
89#define ASSERT(condition, ...) \
90 util::assertImpl(CURRENT_SRC_LOCATION, #condition, static_cast<bool>(condition), __VA_ARGS__)
static Logger::Pump fatal(SourceLocationType const &loc=CURRENT_SRC_LOCATION)
Globally accesible General logger at Severity::FTL severity.
Definition Logger.hpp:352
A class representing the source location of the current code.
Definition SourceLocation.hpp:52
constexpr std::string_view file_name() const
Get the file name.
Definition SourceLocation.hpp:73
constexpr std::size_t line() const
Get the line number.
Definition SourceLocation.hpp:84
This namespace contains various utilities.
Definition AccountUtils.hpp:30
constexpr void assertImpl(SourceLocationType const location, char const *expression, bool const condition, fmt::format_string< Args... > format, Args &&... args)
Assert that a condition is true.
Definition Assert.hpp:51