3#include "util/SourceLocation.hpp"
5#include <boost/log/core/core.hpp>
10#ifndef CLIO_WITHOUT_STACKTRACE
11#include <boost/stacktrace.hpp>
12#include <boost/stacktrace/stacktrace.hpp>
14#include <fmt/format.h>
22 using ActionType = std::function<void(std::string_view)>;
25 static ActionType action;
29 call(std::string_view message);
32 setAction(ActionType newAction);
39 defaultAction(std::string_view message);
53template <
typename... Args>
56 SourceLocationType
const location,
57 char const* expression,
59 fmt::format_string<Args...> format,
64#ifndef CLIO_WITHOUT_STACKTRACE
65 auto const resultMessage = fmt::format(
66 "Assertion '{}' failed at {}:{}:\n{}\nStacktrace:\n{}",
70 fmt::format(format, std::forward<Args>(args)...),
71 boost::stacktrace::to_string(boost::stacktrace::stacktrace())
74 auto const resultMessage = fmt::format(
75 "Assertion '{}' failed at {}:{}:\n{}",
79 fmt::format(format, std::forward<Args>(args)...)
83 OnAssert::call(resultMessage);
89#define ASSERT(condition, ...) \
90 util::impl::assertImpl( \
91 CURRENT_SRC_LOCATION, #condition, static_cast<bool>(condition), __VA_ARGS__ \
constexpr std::string_view file_name() const
Get the file name.
Definition SourceLocation.hpp:54
constexpr std::size_t line() const
Get the line number.
Definition SourceLocation.hpp:65