12 #ifndef INCLUDED_GR_LOGGER_H 13 #define INCLUDED_GR_LOGGER_H 20 #ifdef DISABLE_LOGGER_H 36 #include <spdlog/common.h> 37 #include <spdlog/fmt/fmt.h> 38 #include <spdlog/fmt/ostr.h> 41 #include <spdlog/spdlog.h> 43 #include <spdlog/sinks/dist_sink.h> 45 #include <boost/format.hpp> 59 void operator=(
logging const&) =
delete;
76 spdlog::sink_ptr default_backend()
const;
78 void add_default_sink(
const spdlog::sink_ptr& sink);
80 void add_debug_sink(
const spdlog::sink_ptr& sink);
82 void add_default_console_sink();
84 void add_debug_console_sink();
86 static constexpr
const char* default_pattern =
"%n :%l: %v";
90 std::shared_ptr<spdlog::sinks::dist_sink_mt> _default_backend, _debug_backend;
123 using underlying_logger_ptr = std::shared_ptr<spdlog::logger>;
134 logger(
const std::string& logger_name);
144 void set_level(
const std::string& level);
148 void get_level(std::string& level)
const;
149 const std::string get_string_level()
const;
152 const std::string& name()
const;
153 void set_name(
const std::string& name);
156 template <
typename... Args>
157 inline void trace(
const spdlog::string_view_t&
msg,
const Args&... args)
159 d_logger->trace(
msg, args...);
163 template <
typename... Args>
164 inline void debug(
const spdlog::string_view_t&
msg,
const Args&... args)
166 d_logger->debug(
msg, args...);
170 template <
typename... Args>
171 inline void info(
const spdlog::string_view_t&
msg,
const Args&... args)
173 d_logger->info(
msg, args...);
177 template <
typename... Args>
178 inline void notice(
const spdlog::string_view_t&
msg,
const Args&... args)
180 d_logger->info(
msg, args...);
184 template <
typename... Args>
185 inline void warn(
const spdlog::string_view_t&
msg,
const Args&... args)
187 d_logger->warn(
msg, args...);
191 template <
typename... Args>
192 inline void error(
const spdlog::string_view_t&
msg,
const Args&... args)
194 d_logger->error(
msg, args...);
198 template <
typename... Args>
199 inline void crit(
const spdlog::string_view_t&
msg,
const Args&... args)
201 d_logger->critical(
msg, args...);
205 template <
typename... Args>
206 inline void alert(
const spdlog::string_view_t&
msg,
const Args&... args)
208 d_logger->critical(
msg, args...);
212 template <
typename... Args>
213 inline void fatal(
const spdlog::string_view_t&
msg,
const Args&... args)
215 d_logger->critical(
msg, args...);
219 template <
typename... Args>
220 inline void emerg(
const spdlog::string_view_t&
msg,
const Args&... args)
222 d_logger->critical(
msg, args...);
225 template <
typename... Args>
226 inline void log(spdlog::level::level_enum level,
227 const spdlog::string_view_t&
msg,
230 d_logger->log(level,
msg, args...);
250 #define GR_LOG_TRACE(log, msg) \ 252 log->d_logger->trace(msg); \ 255 #define GR_LOG_DEBUG(log, msg) \ 257 log->d_logger->debug(msg); \ 260 #define GR_LOG_INFO(log, msg) \ 262 log->d_logger->info(msg); \ 265 #define GR_LOG_NOTICE(log, msg) \ 267 log->d_logger->info(msg); \ 271 #define GR_LOG_WARN(log, msg) \ 273 log->d_logger->warn(msg); \ 276 #define GR_LOG_ERROR(log, msg) \ 278 log->d_logger->error(msg); \ 281 #define GR_LOG_CRIT(log, msg) \ 283 log->d_logger->critical(msg); \ 286 #define GR_LOG_ALERT(log, msg) \ 288 log->d_logger->critical(msg); \ 291 #define GR_LOG_FATAL(log, msg) \ 293 log->d_logger->critical(msg); \ 296 #define GR_LOG_EMERG(log, msg) \ 298 log->d_logger->critical(msg); \ 303 struct fmt::formatter<boost::format> : formatter<string_view> {
305 template <
typename FormatContext>
306 auto format(
const boost::format& bfmt, FormatContext& ctx)
307 -> decltype(formatter<string_view>::format(bfmt.str(), ctx))
309 return formatter<string_view>::format(bfmt.str(), ctx);
void emerg(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:220
GR_RUNTIME_API const pmt::pmt_t msg()
void fatal(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:213
log_level default_level() const
get the default logging level
Definition: logger.h:65
std::shared_ptr< logger > logger_ptr
Definition: logger.h:233
void trace(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for TRACE message
Definition: logger.h:157
void error(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for ERROR message
Definition: logger.h:192
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:18
GR_RUNTIME_API bool configure_default_loggers(gr::logger_ptr &l, gr::logger_ptr &d, const std::string &name)
void warn(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for WARN message
Definition: logger.h:185
GNU Radio logging wrapper.
Definition: basic_block.h:29
log_level debug_level() const
get the debug logging level
Definition: logger.h:68
void info(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for INFO message
Definition: logger.h:171
void log(spdlog::level::level_enum level, const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for logging with ad-hoc adjustable level
Definition: logger.h:226
void crit(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message
Definition: logger.h:199
underlying_logger_ptr d_logger
Definition: logger.h:140
GR_LOG macrosThese macros wrap the standard LOG4CPP_LEVEL macros. The available macros are: LOG_DEBUG...
Definition: logger.h:118
void alert(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:206
void debug(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for DEBUG message
Definition: logger.h:164
void notice(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for INFO message, DEPRECATED
Definition: logger.h:178
spdlog::level::level_enum log_level
Definition: logger.h:48