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> 54 void operator=(
logging const&) =
delete;
62 spdlog::sink_ptr default_backend()
const;
64 void add_default_sink(
const spdlog::sink_ptr& sink);
66 void add_debug_sink(
const spdlog::sink_ptr& sink);
68 void add_default_console_sink();
70 void add_debug_console_sink();
72 static constexpr
const char* default_pattern =
"%n :%l: %v";
76 const log_level _default_level, _debug_level;
77 std::shared_ptr<spdlog::sinks::dist_sink_mt> _default_backend, _debug_backend;
110 using underlying_logger_ptr = std::shared_ptr<spdlog::logger>;
117 logger(
const std::string& logger_name);
127 void set_level(
const std::string& level);
131 void get_level(std::string& level)
const;
132 const std::string get_string_level()
const;
135 const std::string& name()
const;
136 void set_name(
const std::string& name);
139 template <
typename... Args>
140 inline void trace(
const spdlog::string_view_t&
msg,
const Args&... args)
142 d_logger->trace(
msg, args...);
146 template <
typename... Args>
147 inline void debug(
const spdlog::string_view_t&
msg,
const Args&... args)
149 d_logger->debug(
msg, args...);
153 template <
typename... Args>
154 inline void info(
const spdlog::string_view_t&
msg,
const Args&... args)
156 d_logger->info(
msg, args...);
160 template <
typename... Args>
161 inline void notice(
const spdlog::string_view_t&
msg,
const Args&... args)
163 d_logger->info(
msg, args...);
167 template <
typename... Args>
168 inline void warn(
const spdlog::string_view_t&
msg,
const Args&... args)
170 d_logger->warn(
msg, args...);
174 template <
typename... Args>
175 inline void error(
const spdlog::string_view_t&
msg,
const Args&... args)
177 d_logger->error(
msg, args...);
181 template <
typename... Args>
182 inline void crit(
const spdlog::string_view_t&
msg,
const Args&... args)
184 d_logger->critical(
msg, args...);
188 template <
typename... Args>
189 inline void alert(
const spdlog::string_view_t&
msg,
const Args&... args)
191 d_logger->critical(
msg, args...);
195 template <
typename... Args>
196 inline void fatal(
const spdlog::string_view_t&
msg,
const Args&... args)
198 d_logger->critical(
msg, args...);
202 template <
typename... Args>
203 inline void emerg(
const spdlog::string_view_t&
msg,
const Args&... args)
205 d_logger->critical(
msg, args...);
225 #define GR_LOG_TRACE(log, msg) \ 227 log->d_logger->trace(msg); \ 230 #define GR_LOG_DEBUG(log, msg) \ 232 log->d_logger->debug(msg); \ 235 #define GR_LOG_INFO(log, msg) \ 237 log->d_logger->info(msg); \ 240 #define GR_LOG_NOTICE(log, msg) \ 242 log->d_logger->info(msg); \ 246 #define GR_LOG_WARN(log, msg) \ 248 log->d_logger->warn(msg); \ 251 #define GR_LOG_ERROR(log, msg) \ 253 log->d_logger->error(msg); \ 256 #define GR_LOG_CRIT(log, msg) \ 258 log->d_logger->critical(msg); \ 261 #define GR_LOG_ALERT(log, msg) \ 263 log->d_logger->critical(msg); \ 266 #define GR_LOG_FATAL(log, msg) \ 268 log->d_logger->critical(msg); \ 271 #define GR_LOG_EMERG(log, msg) \ 273 log->d_logger->critical(msg); \ 278 struct fmt::formatter<boost::format> : formatter<string_view> {
280 template <
typename FormatContext>
281 auto format(
const boost::format& bfmt, FormatContext& ctx)
282 -> decltype(formatter<string_view>::format(bfmt.str(), ctx))
284 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:203
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:196
log_level default_level() const
get the singleton
Definition: logger.h:58
std::shared_ptr< logger > logger_ptr
Definition: logger.h:208
void trace(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for TRACE message
Definition: logger.h:140
void error(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for ERROR message
Definition: logger.h:175
#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:168
GNU Radio logging wrapper.
Definition: basic_block.h:29
log_level debug_level() const
get the debug logging level
Definition: logger.h:61
void info(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for INFO message
Definition: logger.h:154
void crit(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message
Definition: logger.h:182
underlying_logger_ptr d_logger
Definition: logger.h:123
GR_LOG macrosThese macros wrap the standard LOG4CPP_LEVEL macros. The available macros are: LOG_DEBUG...
Definition: logger.h:105
void alert(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:189
void debug(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for DEBUG message
Definition: logger.h:147
void notice(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for INFO message, DEPRECATED
Definition: logger.h:161
spdlog::level::level_enum log_level
Definition: logger.h:48