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> 21 void fatalError(
const std::string& msg) __attribute__((noreturn));
24 void warning(
const std::string& msg);
31 #define HILTI_RT_DEBUG(stream, msg) \ 33 if ( ::hilti::rt::detail::globalState()->debug_logger && \ 34 ::hilti::rt::detail::globalState()->debug_logger->isEnabled(stream) ) \ 35 ::hilti::rt::debug::detail::print(stream, msg); \ 39 #define __location__(x) ::hilti::rt::debug::setLocation(x); 45 inline void print(
const std::string& stream,
const char* msg) {
46 if ( ::hilti::rt::detail::globalState()->debug_logger )
47 ::hilti::rt::detail::globalState()->debug_logger->print(stream, msg);
51 inline void print(
const std::string& stream,
const std::string_view& s) {
52 if ( ::hilti::rt::detail::globalState()->debug_logger )
53 ::hilti::rt::detail::globalState()->debug_logger->print(stream, hilti::rt::escapeBytes(s,
false));
56 template<typename T, typename std::enable_if_t<not std::is_convertible<T, std::string_view>::value>* =
nullptr>
58 inline void print(
const std::string& stream,
const T& t) {
59 if ( ::hilti::rt::detail::globalState()->debug_logger )
60 ::hilti::rt::detail::globalState()->debug_logger->print(stream, hilti::rt::to_string_for_print(t));
65 inline bool isEnabled(
const std::string& stream) {
66 return ::hilti::rt::detail::globalState()->debug_logger &&
67 ::hilti::rt::detail::globalState()->debug_logger->isEnabled(stream);
71 inline void indent(
const std::string& stream) {
72 if ( ::hilti::rt::detail::globalState()->debug_logger )
73 ::hilti::rt::detail::globalState()->debug_logger->indent(stream);
77 inline void dedent(
const std::string& stream) {
78 if ( ::hilti::rt::detail::globalState()->debug_logger )
79 ::hilti::rt::detail::globalState()->debug_logger->dedent(stream);
86 const auto context = ::hilti::rt::context::detail::current();
87 return context ? context->source_location :
nullptr;
94 inline void setLocation(
const char* l =
nullptr) {
95 if (
auto context = ::hilti::rt::context::detail::current() )
96 context->source_location = l;
105 inline void print(
const std::string& stream, T&& msg) {
106 if ( ::hilti::rt::detail::globalState()->debug_logger &&
107 ::hilti::rt::detail::globalState()->debug_logger->isEnabled(stream) )
108 ::hilti::rt::debug::detail::print(stream, std::forward<T>(msg));
void fatalError(const std::string &msg) __attribute__((noreturn))
Definition: logging.cc:21
void print(const T &t, bool newline=true)
Definition: hilti.h:22
Definition: location.h:94
void warning(const std::string &msg)
Definition: logging.cc:28