GNU Radio 3.7.1 C++ API
|
#include <gnuradio/api.h>
#include <assert.h>
#include <iostream>
#include <time.h>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <boost/format.hpp>
#include <pmt/pmt.h>
#include <log4cpp/Category.hh>
#include <log4cpp/PropertyConfigurator.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/RollingFileAppender.hh>
#include <log4cpp/OstreamAppender.hh>
#include <log4cpp/PatternLayout.hh>
Go to the source code of this file.
Classes | |
class | gr::logger_config |
Class to control configuration of logger. This is a singleton that cna launch a thread to wathc a config file for changes. More... | |
class | gr::logger |
Logger class for referencing loggers in python. Not needed in C++ (use macros) Wraps and manipulates loggers for python as python has no macros. More... | |
Namespaces | |
namespace | gr |
Include this header to use the message passing features. | |
Defines | |
#define | ENABLE_GR_LOG |
GNU Radio logging wrapper for log4cpp library (C++ port of log4j) | |
#define | HAVE_LOG4CPP |
#define | GR_LOG_DECLARE_LOGPTR(logger) gr::logger_ptr logger; |
#define | GR_LOG_ASSIGN_LOGPTR(logger, name) logger = gr::logger_get_logger(name); |
#define | GR_CONFIG_LOGGER(config) gr::logger_config::load_config(config) |
#define | GR_CONFIG_AND_WATCH_LOGGER(config, period) gr::logger_config::load_config(config,period) |
#define | GR_LOG_GETLOGGER(logger, name) gr::logger_ptr logger = gr::logger_get_logger(name); |
#define | GR_SET_LEVEL(name, level) |
#define | GR_LOG_SET_LEVEL(logger, level) gr::logger_set_level(logger, level); |
#define | GR_GET_LEVEL(name, level) |
#define | GR_LOG_GET_LEVEL(logger, level) gr::logger_get_level(logger,level); |
#define | GR_ADD_APPENDER(name, appender) |
#define | GR_LOG_ADD_APPENDER(logger, appender) |
#define | GR_ADD_CONSOLE_APPENDER(name, target, pattern) |
#define | GR_LOG_ADD_CONSOLE_APPENDER(logger, target, pattern) |
#define | GR_ADD_FILE_APPENDER(name, filename, append, pattern) |
#define | GR_LOG_ADD_FILE_APPENDER(logger, filename, append, pattern) |
#define | GR_ADD_ROLLINGFILE_APPENDER(name, filename, filesize, bkup_index, append, mode, pattern) |
#define | GR_LOG_ADD_ROLLINGFILE_APPENDER(logger, filename, filesize, bkup_index, append, mode, pattern) |
#define | GR_GET_LOGGER_NAMES(names) |
#define | GR_RESET_CONFIGURATION() gr::logger_config::reset_config(); |
#define | GR_DEBUG(name, msg) |
#define | GR_INFO(name, msg) |
#define | GR_NOTICE(name, msg) |
#define | GR_WARN(name, msg) |
#define | GR_ERROR(name, msg) |
#define | GR_CRIT(name, msg) |
#define | GR_ALERT(name, msg) |
#define | GR_FATAL(name, msg) |
#define | GR_EMERG(name, msg) |
#define | GR_ERRORIF(name, cond, msg) |
#define | GR_ASSERT(name, cond, msg) |
#define | GR_LOG_DEBUG(logger, msg) |
#define | GR_LOG_INFO(logger, msg) |
#define | GR_LOG_NOTICE(logger, msg) |
#define | GR_LOG_WARN(logger, msg) |
#define | GR_LOG_ERROR(logger, msg) |
#define | GR_LOG_CRIT(logger, msg) |
#define | GR_LOG_ALERT(logger, msg) |
#define | GR_LOG_FATAL(logger, msg) |
#define | GR_LOG_EMERG(logger, msg) |
#define | GR_LOG_ERRORIF(logger, cond, msg) |
#define | GR_LOG_ASSERT(logger, cond, msg) |
Typedefs | |
typedef log4cpp::Category * | gr::logger_ptr |
GR_LOG macrosThese macros wrap the standard LOG4CPP_LEVEL macros. The availablie macros are: LOG_DEBUG LOG_INFO LOG_WARN LOG_TRACE LOG_ERROR LOG_ALERT LOG_CRIT LOG_FATAL LOG_EMERG. | |
Functions | |
GR_RUNTIME_API logger_ptr | gr::logger_get_logger (std::string name) |
Retrieve a pointer to a logger by name. | |
GR_RUNTIME_API bool | gr::logger_load_config (const std::string &config_filename="") |
Load logger's configuration file. | |
GR_RUNTIME_API void | gr::logger_reset_config (void) |
Reset logger's configuration file. | |
GR_RUNTIME_API void | gr::logger_set_level (logger_ptr logger, const std::string &level) |
Set the logger's output level. | |
GR_RUNTIME_API void | gr::logger_set_level (logger_ptr logger, log4cpp::Priority::Value level) |
Set the logger's output level. | |
GR_RUNTIME_API void | gr::logger_get_level (logger_ptr logger, std::string &level) |
Get the logger's output level. | |
GR_RUNTIME_API void | gr::logger_get_level (logger_ptr logger, log4cpp::Priority::Value &level) |
Get the logger's output level. | |
GR_RUNTIME_API void | gr::logger_add_appender (logger_ptr logger, std::string appender) |
Add console appender to a given logger. | |
GR_RUNTIME_API void | gr::logger_add_console_appender (logger_ptr logger, std::string target, std::string pattern) |
Add console appender to a given logger. | |
GR_RUNTIME_API void | gr::logger_add_file_appender (logger_ptr logger, std::string filename, bool append, std::string pattern) |
Add file appender to a given logger. | |
GR_RUNTIME_API void | gr::logger_add_rollingfile_appender (logger_ptr logger, std::string filename, size_t filesize, int bkup_index, bool append, mode_t mode, std::string pattern) |
Add rolling file appender to a given logger. | |
GR_RUNTIME_API std::vector < std::string > | gr::logger_get_logger_names (void) |
Add rolling file appender to a given logger. | |
GR_RUNTIME_API void | gr_logger_config (const std::string config_filename, unsigned int watch_period=0) |
Function to call configuration macro from python. Note: Configuration is only updated if filename or watch_period has changed. | |
GR_RUNTIME_API std::vector < std::string > | gr_logger_get_logger_names (void) |
Function to return logger names to python. | |
GR_RUNTIME_API void | gr_logger_reset_config (void) |
Function to reset logger configuration from python. |
#define ENABLE_GR_LOG |
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
#define GR_ADD_APPENDER | ( | name, | |
appender | |||
) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ gr::logger_add_appender(logger,appender);}
#define GR_ADD_CONSOLE_APPENDER | ( | name, | |
target, | |||
pattern | |||
) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ gr::logger_add_console_appender(logger,target,pattern);}
#define GR_ADD_FILE_APPENDER | ( | name, | |
filename, | |||
append, | |||
pattern | |||
) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ gr::logger_add_file_appender(logger,filename,append,pattern);}
#define GR_ADD_ROLLINGFILE_APPENDER | ( | name, | |
filename, | |||
filesize, | |||
bkup_index, | |||
append, | |||
mode, | |||
pattern | |||
) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ gr::logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);}
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::ALERT << msg << log4cpp::eol;}
{ \ if(!(cond)) { \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;} \ assert(0); \ }
#define GR_CONFIG_AND_WATCH_LOGGER | ( | config, | |
period | |||
) | gr::logger_config::load_config(config,period) |
#define GR_CONFIG_LOGGER | ( | config | ) | gr::logger_config::load_config(config) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::CRIT << msg << log4cpp::eol;}
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::DEBUG << msg << log4cpp::eol;}
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;}
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;}
#define GR_ERRORIF | ( | name, | |
cond, | |||
msg | |||
) |
{ \ if((cond)) { \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;} \ }
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::FATAL << msg << log4cpp::eol;}
#define GR_GET_LEVEL | ( | name, | |
level | |||
) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ gr::logger_get_level(logger,level);}
#define GR_GET_LOGGER_NAMES | ( | names | ) |
{ \ names = gr::logger_get_logger_names();}
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::INFO << msg << log4cpp::eol;}
#define GR_LOG_ADD_APPENDER | ( | logger, | |
appender | |||
) |
{ \ gr::logger_add_appender(logger, appender);}
Referenced by gr::logger::add_appender().
#define GR_LOG_ADD_CONSOLE_APPENDER | ( | logger, | |
target, | |||
pattern | |||
) |
{ \ gr::logger_add_console_appender(logger,target,pattern);}
Referenced by gr::logger::add_console_appender().
#define GR_LOG_ADD_FILE_APPENDER | ( | logger, | |
filename, | |||
append, | |||
pattern | |||
) |
{ \ gr::logger_add_file_appender(logger,filename,append,pattern);}
Referenced by gr::logger::add_file_appender().
#define GR_LOG_ADD_ROLLINGFILE_APPENDER | ( | logger, | |
filename, | |||
filesize, | |||
bkup_index, | |||
append, | |||
mode, | |||
pattern | |||
) |
{ \ gr::logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);}
Referenced by gr::logger::add_rollingfile_appender().
#define GR_LOG_ALERT | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::ALERT << msg << log4cpp::eol;}
Referenced by gr::logger::alert().
#define GR_LOG_ASSERT | ( | logger, | |
cond, | |||
msg | |||
) |
{ \ if(!(cond)) { \ *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol; \ assert(0);} \ }
Referenced by gr::logger::log_assert().
#define GR_LOG_ASSIGN_LOGPTR | ( | logger, | |
name | |||
) | logger = gr::logger_get_logger(name); |
Referenced by gr::logger::logger().
#define GR_LOG_CRIT | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::CRIT << msg << log4cpp::eol;}
Referenced by gr::logger::crit().
#define GR_LOG_DEBUG | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::DEBUG << msg << log4cpp::eol;}
Referenced by gr::logger::debug().
#define GR_LOG_DECLARE_LOGPTR | ( | logger | ) | gr::logger_ptr logger; |
#define GR_LOG_EMERG | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::EMERG << msg << log4cpp::eol;}
Referenced by gr::logger::emerg().
#define GR_LOG_ERROR | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::ERROR << msg << log4cpp::eol;}
Referenced by gr::logger::error().
#define GR_LOG_ERRORIF | ( | logger, | |
cond, | |||
msg | |||
) |
{ \ if((cond)) { \ *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;} \ }
Referenced by gr::logger::errorIF().
#define GR_LOG_FATAL | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::FATAL << msg << log4cpp::eol;}
Referenced by gr::logger::fatal().
#define GR_LOG_GET_LEVEL | ( | logger, | |
level | |||
) | gr::logger_get_level(logger,level); |
Referenced by gr::logger::get_level().
#define GR_LOG_GETLOGGER | ( | logger, | |
name | |||
) | gr::logger_ptr logger = gr::logger_get_logger(name); |
#define GR_LOG_INFO | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::INFO << msg << log4cpp::eol;}
Referenced by gr::logger::info().
#define GR_LOG_NOTICE | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::NOTICE << msg << log4cpp::eol;}
Referenced by gr::logger::notice().
#define GR_LOG_SET_LEVEL | ( | logger, | |
level | |||
) | gr::logger_set_level(logger, level); |
Referenced by gr::logger::set_level().
#define GR_LOG_WARN | ( | logger, | |
msg | |||
) |
{ \ *logger << log4cpp::Priority::WARN << msg << log4cpp::eol;}
Referenced by gr::logger::warn().
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger << log4cpp::Priority::NOTICE << msg;}
#define GR_RESET_CONFIGURATION | ( | ) | gr::logger_config::reset_config(); |
#define GR_SET_LEVEL | ( | name, | |
level | |||
) |
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ gr::logger_set_level(logger,level);}
{ \ gr::logger_ptr logger = gr::logger_get_logger(name); \ *logger<< log4cpp::Priority::WARN << msg << log4cpp::eol;}
#define HAVE_LOG4CPP |
GR_RUNTIME_API void gr_logger_config | ( | const std::string | config_filename, |
unsigned int | watch_period = 0 |
||
) |
Function to call configuration macro from python. Note: Configuration is only updated if filename or watch_period has changed.
config_filename | Name of configuration file |
watch_period | Seconds to wait between checking for changes in conf file. Watch_period defaults to 0 in which case the file is not watched for changes |
GR_RUNTIME_API std::vector<std::string> gr_logger_get_logger_names | ( | void | ) |
Function to return logger names to python.
Function to reset logger configuration from python.