Go to the documentation of this file.
11 #include <spdlog/fmt/fmt.h>
12 #include <spdlog/fmt/ostr.h>
13 #include <spdlog/logger.h>
16 #if FMT_VERSION >= 9 * 10000
17 # define MC_FMT_STREAMED(X) fmt::streamed(X)
19 # define MC_FMT_STREAMED(X) X
22 #define BOOST_STACKTRACE_LINK
23 #include <boost/stacktrace.hpp>
46 template<
typename ExceptionT = std::runtime_error,
typename... Args>
49 auto message = fmt::format(std::forward<Args>(args)...);
53 throw ExceptionT(message);
56 template<
typename... Args>
62 template<
typename... Args>
68 template<
typename... Args>
74 template<
typename... Args>
80 template<
typename... Args>
86 template<
typename... Args>
109 # define LOG_ERROR(args) \
110 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::error instead\""); \
111 std::cerr << mc_rtc::OUT_RED << args << mc_rtc::OUT_NONE << "\n";
112 # define LOG_WARNING(args) \
113 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::warning instead\""); \
114 std::cerr << mc_rtc::OUT_PURPLE << args << mc_rtc::OUT_NONE << "\n";
115 # define LOG_INFO(args) \
116 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::info instead\""); \
117 std::cout << mc_rtc::OUT_BLUE << args << mc_rtc::OUT_NONE << "\n";
118 # define LOG_SUCCESS(args) \
119 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::success instead\""); \
120 std::cout << mc_rtc::OUT_GREEN << args << mc_rtc::OUT_NONE << "\n";
122 # define LOG_ERROR_AND_THROW(exception_type, args) \
124 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::error_and_throw<exception_type> instead\""); \
125 std::stringstream strstrm; \
127 LOG_ERROR(strstrm.str()) \
128 throw exception_type(strstrm.str()); \
133 # include <windows.h>
136 static const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
144 # define __MC_RTC_STR2__(x) #x
145 # define __MC_RTC_STR1__(x) __MC_RTC_STR2__(x)
146 # define __MC_RTC_PRAGMA_LOC__ __FILE__ "("__MC_RTC_STR1__(__LINE__) ") "
148 # define LOG_ERROR(args) \
149 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::error instead")); \
150 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_RED); \
151 std::cerr << args << std::endl; \
152 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
154 # define LOG_WARNING(args) \
155 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::warning instead")); \
156 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_PURPLE); \
157 std::cerr << args << std::endl; \
158 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
160 # define LOG_INFO(args) \
161 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::info instead")); \
162 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_BLUE); \
163 std::cout << args << std::endl; \
164 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
166 # define LOG_SUCCESS(args) \
167 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::success instead")); \
168 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_GREEN); \
169 std::cout << args << std::endl; \
170 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
172 # define LOG_ERROR_AND_THROW(exception_type, args) \
175 message(__MC_RTC_PRAGMA_LOC__ \
176 ": warning: this macro is deprecated, use mc_rtc::log::error_and_throw<exception_type> instead")); \
177 std::stringstream strstrm; \
179 LOG_ERROR(strstrm.str()) \
180 throw exception_type(strstrm.str()); \
void critical(Args &&... args)
Definition: logging.h:57
constexpr auto OUT_BLUE
Definition: logging.h:102
MC_RTC_UTILS_DLLAPI spdlog::logger & success()
constexpr auto OUT_NONE
Definition: logging.h:101
constexpr auto OUT_RED
Definition: logging.h:105
MC_RTC_UTILS_DLLAPI void disable_notifications()
constexpr auto OUT_GREEN
Definition: logging.h:103
void error_and_throw(Args &&... args)
Definition: logging.h:47
void notify(Args &&... args)
Definition: logging.h:87
void warning(Args &&... args)
Definition: logging.h:69
#define MC_RTC_UTILS_DLLAPI
Definition: utils_api.h:50
MC_RTC_UTILS_DLLAPI spdlog::logger & info()
void info(Args &&... args)
Definition: logging.h:75
#define MC_FMT_STREAMED(X)
Definition: logging.h:19
void error(Args &&... args)
Definition: logging.h:63
MC_RTC_UTILS_DLLAPI void notify(const std::string &message)
void success(Args &&... args)
Definition: logging.h:81
constexpr auto OUT_PURPLE
Definition: logging.h:104
MC_RTC_UTILS_DLLAPI spdlog::logger & cerr()