dReal4
logging.h
1 #pragma once
2 
3 #include "fmt/ostream.h"
4 #include "spdlog/spdlog.h"
5 
6 namespace dreal {
7 
8 /// Provide a global logger. See the following usage:
9 ///
10 /// <pre>
11 /// DREAL_LOG_TRACE("message with param {0}, {1}", arg1, arg2);
12 /// DREAL_LOG_DEBUG("message with param {0}, {1}", arg1, arg2);
13 /// DREAL_LOG_INFO("Support for int: {0:d}; hex: {0:x};", 42, 32);
14 /// DREAL_LOG_WARN("Support for floats {:03.2f}", 1.23456);
15 /// DREAL_LOG_ERROR("Positional args are {1} {0}..", "too", "supported");
16 /// DREAL_LOG_CRITICAL("{:<30}", "left aligned");
17 /// </pre>
18 ///
19 /// Please check https://github.com/gabime/spdlog for more information.
20 spdlog::logger* log();
21 
22 } // namespace dreal
23 
24 #define DREAL_LOG_TRACE(...) \
25  do { \
26  if (::dreal::log()->should_log(spdlog::level::trace)) { \
27  ::dreal::log()->trace(__VA_ARGS__); \
28  } \
29  } while (0)
30 
31 #define DREAL_LOG_DEBUG(...) \
32  do { \
33  if (::dreal::log()->should_log(spdlog::level::debug)) { \
34  ::dreal::log()->debug(__VA_ARGS__); \
35  } \
36  } while (0)
37 
38 #define DREAL_LOG_INFO(...) \
39  do { \
40  ::dreal::log()->info(__VA_ARGS__); \
41  } while (0)
42 
43 #define DREAL_LOG_WARN(...) \
44  do { \
45  ::dreal::log()->warn(__VA_ARGS__); \
46  } while (0)
47 
48 #define DREAL_LOG_ERROR(...) \
49  do { \
50  ::dreal::log()->error(__VA_ARGS__); \
51  } while (0)
52 
53 #define DREAL_LOG_CRITICAL(...) \
54  do { \
55  ::dreal::log()->critical(__VA_ARGS__); \
56  } while (0)
57 
58 #define DREAL_LOG_TRACE_ENABLED \
59  (::dreal::log()->should_log(spdlog::level::trace))
60 #define DREAL_LOG_DEBUG_ENABLED \
61  (::dreal::log()->should_log(spdlog::level::debug))
62 #define DREAL_LOG_INFO_ENABLED (::dreal::log()->should_log(spdlog::level::info))
63 #define DREAL_LOG_WARN_ENABLED (::dreal::log()->should_log(spdlog::level::warn))
64 #define DREAL_LOG_ERROR_ENABLED (::dreal::log()->should_log(spdlog::level::err))
65 #define DREAL_LOG_CRITICAL_ENABLED \
66  (::dreal::log()->should_log(spdlog::level::critical))
spdlog::logger * log()
Provide a global logger.
Definition: logging.cc:33
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9