summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/logger.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib/logger.cc')
-rw-r--r--gnuradio-runtime/lib/logger.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/logger.cc b/gnuradio-runtime/lib/logger.cc
index bb1d4b4c33..13c8391c8e 100644
--- a/gnuradio-runtime/lib/logger.cc
+++ b/gnuradio-runtime/lib/logger.cc
@@ -417,4 +417,35 @@ namespace gr {
return false;
}
+ bool
+ update_logger_alias(const std::string &name, const std::string &alias)
+ {
+#ifdef ENABLE_GR_LOG
+#ifdef HAVE_LOG4CPP
+ prefs *p = prefs::singleton();
+ std::string log_file = p->get_string("LOG", "log_file", "");
+ std::string debug_file = p->get_string("LOG", "debug_file", "");
+
+ GR_LOG_GETLOGGER(LOG, "gr_log." + name);
+ if(log_file.size() > 0) {
+ if(log_file == "stdout") {
+ boost::format str("gr::log :%%p: %1% - %%m%%n");
+ GR_LOG_SET_CONSOLE_APPENDER(LOG, "cout", boost::str(str % alias));
+ }
+ else if(log_file == "stderr") {
+ boost::format str("gr::log :%%p: %1% - %%m%%n");
+ GR_LOG_SET_CONSOLE_APPENDER(LOG, "cerr", boost::str(str % alias));
+ }
+ else {
+ boost::format str("%%r :%%p: %1% - %%m%%n");
+ GR_LOG_SET_FILE_APPENDER(LOG, log_file, true, boost::str(str % alias));
+ }
+ }
+ return true;
+#endif /* HAVE_LOG4CPP */
+#endif /* ENABLE_GR_LOG */
+
+ return false;
+ }
+
} /* namespace gr */