11 #include <spdlog/fmt/fmt.h>
12 #include <spdlog/fmt/ostr.h>
13 #include <spdlog/logger.h>
15 #define BOOST_STACKTRACE_LINK
16 #include <boost/stacktrace.hpp>
39 template<
typename ExceptionT = std::runtime_error,
typename... Args>
42 auto message = fmt::format(std::forward<Args>(args)...);
46 throw ExceptionT(message);
49 template<
typename... Args>
55 template<
typename... Args>
61 template<
typename... Args>
67 template<
typename... Args>
73 template<
typename... Args>
79 template<
typename... Args>
102 # define LOG_ERROR(args) \
103 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::error instead\""); \
104 std::cerr << mc_rtc::OUT_RED << args << mc_rtc::OUT_NONE << "\n";
105 # define LOG_WARNING(args) \
106 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::warning instead\""); \
107 std::cerr << mc_rtc::OUT_PURPLE << args << mc_rtc::OUT_NONE << "\n";
108 # define LOG_INFO(args) \
109 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::info instead\""); \
110 std::cout << mc_rtc::OUT_BLUE << args << mc_rtc::OUT_NONE << "\n";
111 # define LOG_SUCCESS(args) \
112 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::success instead\""); \
113 std::cout << mc_rtc::OUT_GREEN << args << mc_rtc::OUT_NONE << "\n";
115 # define LOG_ERROR_AND_THROW(exception_type, args) \
117 _Pragma("GCC warning \"This macro is deprecated, use mc_rtc::log::error_and_throw<exception_type> instead\""); \
118 std::stringstream strstrm; \
120 LOG_ERROR(strstrm.str()) \
121 throw exception_type(strstrm.str()); \
126 # include <windows.h>
129 static const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
137 # define __MC_RTC_STR2__(x) #x
138 # define __MC_RTC_STR1__(x) __MC_RTC_STR2__(x)
139 # define __MC_RTC_PRAGMA_LOC__ __FILE__ "("__MC_RTC_STR1__(__LINE__) ") "
141 # define LOG_ERROR(args) \
142 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::error instead")); \
143 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_RED); \
144 std::cerr << args << std::endl; \
145 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
147 # define LOG_WARNING(args) \
148 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::warning instead")); \
149 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_PURPLE); \
150 std::cerr << args << std::endl; \
151 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
153 # define LOG_INFO(args) \
154 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::info instead")); \
155 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_BLUE); \
156 std::cout << args << std::endl; \
157 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
159 # define LOG_SUCCESS(args) \
160 __pragma(message(__MC_RTC_PRAGMA_LOC__ ": warning: this macro is deprecated, use mc_rtc::log::success instead")); \
161 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_GREEN); \
162 std::cout << args << std::endl; \
163 SetConsoleTextAttribute(mc_rtc::hConsole, mc_rtc::OUT_NONE);
165 # define LOG_ERROR_AND_THROW(exception_type, args) \
168 message(__MC_RTC_PRAGMA_LOC__ \
169 ": warning: this macro is deprecated, use mc_rtc::log::error_and_throw<exception_type> instead")); \
170 std::stringstream strstrm; \
172 LOG_ERROR(strstrm.str()) \
173 throw exception_type(strstrm.str()); \
MC_RTC_UTILS_DLLAPI spdlog::logger & info()
MC_RTC_UTILS_DLLAPI spdlog::logger & success()
MC_RTC_UTILS_DLLAPI void disable_notifications()
MC_RTC_UTILS_DLLAPI void notify(const std::string &message)
MC_RTC_UTILS_DLLAPI spdlog::logger & cerr()
void info(Args &&... args)
Definition: logging.h:68
void error_and_throw(Args &&... args)
Definition: logging.h:40
void success(Args &&... args)
Definition: logging.h:74
void notify(Args &&... args)
Definition: logging.h:80
void critical(Args &&... args)
Definition: logging.h:50
void warning(Args &&... args)
Definition: logging.h:62
void error(Args &&... args)
Definition: logging.h:56
constexpr auto OUT_BLUE
Definition: logging.h:95
constexpr auto OUT_GREEN
Definition: logging.h:96
constexpr auto OUT_RED
Definition: logging.h:98
constexpr auto OUT_NONE
Definition: logging.h:94
constexpr auto OUT_PURPLE
Definition: logging.h:97
#define MC_RTC_UTILS_DLLAPI
Definition: utils_api.h:50