8 #include <hilti/rt/debug-logger.h> 9 #include <hilti/rt/global-state.h> 10 #include <hilti/rt/types/string.h> 11 #include <hilti/rt/util.h> 24 void fatalError(
const std::string& msg) __attribute__((noreturn));
27 void warning(
const std::string& msg);
34 #define HILTI_RT_DEBUG(stream, msg) \ 36 if ( ::hilti::rt::detail::globalState()->debug_logger && \ 37 ::hilti::rt::detail::globalState()->debug_logger->isEnabled(stream) ) \ 38 ::hilti::rt::debug::detail::print(stream, msg); \ 42 #define __location__(x) ::hilti::rt::debug::setLocation(x); 48 inline void print(
const std::string& stream,
const char* msg) {
49 if ( ::hilti::rt::detail::globalState()->debug_logger )
50 ::hilti::rt::detail::globalState()->debug_logger->print(stream, msg);
54 inline void print(
const std::string& stream,
const std::string_view& s) {
55 if ( ::hilti::rt::detail::globalState()->debug_logger )
56 ::hilti::rt::detail::globalState()->debug_logger->print(stream, hilti::rt::escapeBytes(s,
false));
59 template<typename T, typename std::enable_if_t<not std::is_convertible<T, std::string_view>::value>* =
nullptr>
61 inline void print(
const std::string& stream,
const T& t) {
62 if ( ::hilti::rt::detail::globalState()->debug_logger )
63 ::hilti::rt::detail::globalState()->debug_logger->print(stream, hilti::rt::to_string_for_print(t));
68 inline bool isEnabled(
const std::string& stream) {
69 return ::hilti::rt::detail::globalState()->debug_logger &&
70 ::hilti::rt::detail::globalState()->debug_logger->isEnabled(stream);
74 inline void indent(
const std::string& stream) {
75 if ( ::hilti::rt::detail::globalState()->debug_logger )
76 ::hilti::rt::detail::globalState()->debug_logger->indent(stream);
80 inline void dedent(
const std::string& stream) {
81 if ( ::hilti::rt::detail::globalState()->debug_logger )
82 ::hilti::rt::detail::globalState()->debug_logger->dedent(stream);
89 const auto context = ::hilti::rt::context::detail::current();
90 return context ? context->source_location :
nullptr;
97 inline void setLocation(
const char* l =
nullptr) {
98 if (
auto context = ::hilti::rt::context::detail::current() )
99 context->source_location = l;
void fatalError(const std::string &msg) __attribute__((noreturn))
Definition: logging.cc:22
void print(const T &t, bool newline=true)
Definition: hilti.h:22
Definition: location.h:93
void warning(const std::string &msg)
Definition: logging.cc:29