summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/logger.cc
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-12-04 10:31:24 -0500
committerTom Rondeau <tom@trondeau.com>2014-12-04 10:31:24 -0500
commit56f69533d1fa2114cd0a70516bdcc14243cfedfe (patch)
tree4a11337f2826c9860196d260885a483a90bf8d86 /gnuradio-runtime/lib/logger.cc
parent8236ec001ecacc8580325209bb79fee622939926 (diff)
logger: adds a function to the logger facilities that allows us to update the format of the logging output.
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 */