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>
40 #include <spdlog/spdlog.h>
42 #include <spdlog/sinks/dist_sink.h>
44 #include <boost/format.hpp>
71 static constexpr
const char* default_pattern =
"%n :%l: %v";
75 const log_level _default_level, _debug_level;
76 std::shared_ptr<spdlog::sinks::dist_sink_mt> _default_backend, _debug_backend;
109 using underlying_logger_ptr = std::shared_ptr<spdlog::logger>;
134 const std::string&
name()
const;
138 template <
typename... Args>
139 inline void trace(
const spdlog::string_view_t&
msg,
const Args&... args)
141 d_logger->trace(
msg, args...);
145 template <
typename... Args>
146 inline void debug(
const spdlog::string_view_t&
msg,
const Args&... args)
148 d_logger->debug(
msg, args...);
152 template <
typename... Args>
153 inline void info(
const spdlog::string_view_t&
msg,
const Args&... args)
155 d_logger->info(
msg, args...);
159 template <
typename... Args>
160 inline void notice(
const spdlog::string_view_t&
msg,
const Args&... args)
162 d_logger->info(
msg, args...);
166 template <
typename... Args>
167 inline void warn(
const spdlog::string_view_t&
msg,
const Args&... args)
169 d_logger->warn(
msg, args...);
173 template <
typename... Args>
174 inline void error(
const spdlog::string_view_t&
msg,
const Args&... args)
176 d_logger->error(
msg, args...);
180 template <
typename... Args>
181 inline void crit(
const spdlog::string_view_t&
msg,
const Args&... args)
183 d_logger->critical(
msg, args...);
187 template <
typename... Args>
188 inline void alert(
const spdlog::string_view_t&
msg,
const Args&... args)
190 d_logger->critical(
msg, args...);
194 template <
typename... Args>
195 inline void fatal(
const spdlog::string_view_t&
msg,
const Args&... args)
197 d_logger->critical(
msg, args...);
201 template <
typename... Args>
202 inline void emerg(
const spdlog::string_view_t&
msg,
const Args&... args)
204 d_logger->critical(
msg, args...);
224 #define GR_LOG_TRACE(log, msg) \
226 log->d_logger->trace(msg); \
229 #define GR_LOG_DEBUG(log, msg) \
231 log->d_logger->debug(msg); \
234 #define GR_LOG_INFO(log, msg) \
236 log->d_logger->info(msg); \
239 #define GR_LOG_NOTICE(log, msg) \
241 log->d_logger->info(msg); \
245 #define GR_LOG_WARN(log, msg) \
247 log->d_logger->warn(msg); \
250 #define GR_LOG_ERROR(log, msg) \
252 log->d_logger->error(msg); \
255 #define GR_LOG_CRIT(log, msg) \
257 log->d_logger->critical(msg); \
260 #define GR_LOG_ALERT(log, msg) \
262 log->d_logger->critical(msg); \
265 #define GR_LOG_FATAL(log, msg) \
267 log->d_logger->critical(msg); \
270 #define GR_LOG_EMERG(log, msg) \
272 log->d_logger->critical(msg); \
277 struct fmt::formatter<boost::format> : formatter<string_view> {
279 template <
typename FormatContext>
280 auto format(
const boost::format& bfmt, FormatContext& ctx)
281 -> decltype(formatter<string_view>::format(bfmt.str(), ctx))
283 return formatter<string_view>::format(bfmt.str(), ctx);
GR_LOG macros.
Definition: logger.h:105
void crit(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message
Definition: logger.h:181
void set_name(const std::string &name)
const std::string & name() const
void get_level(std::string &level) const
inline function, wrapper to get the logger level
void emerg(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:202
void alert(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:188
~logger()=default
Destructor.
underlying_logger_ptr d_logger
Definition: logger.h:122
void debug(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for DEBUG message
Definition: logger.h:146
void fatal(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for CRITICAL message, DEPRECATED
Definition: logger.h:195
logger(const std::string &logger_name)
constructor Provide name of logger to associate with this class
void trace(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for TRACE message
Definition: logger.h:139
void error(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for ERROR message
Definition: logger.h:174
void set_level(const log_level level)
void set_level(const std::string &level)
inline function, wrapper to set the logger level
void notice(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for INFO message, DEPRECATED
Definition: logger.h:160
log_level get_level() const
void warn(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for WARN message
Definition: logger.h:167
const std::string get_string_level() const
void info(const spdlog::string_view_t &msg, const Args &... args)
inline function, wrapper for INFO message
Definition: logger.h:153
void add_default_sink(const spdlog::sink_ptr &sink)
adds a logging sink
spdlog::sink_ptr default_backend() const
void operator=(logging const &)=delete
void add_default_console_sink()
add a default-constructed console sink to the default logger
logging(logging const &)=delete
void add_debug_console_sink()
add a default-constructed console sink to the debugging logger
log_level debug_level() const
get the debug logging level
Definition: logger.h:60
static logging & singleton()
void add_debug_sink(const spdlog::sink_ptr &sink)
adds a debugging sink
log_level default_level() const
get the singleton
Definition: logger.h:57
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:18
GR_RUNTIME_API const pmt::pmt_t msg()
GNU Radio logging wrapper.
Definition: basic_block.h:29
std::shared_ptr< logger > logger_ptr
Definition: logger.h:207
GR_RUNTIME_API bool configure_default_loggers(gr::logger_ptr &l, gr::logger_ptr &d, const std::string &name)
spdlog::level::level_enum log_level
Definition: logger.h:47