summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2012-06-11 15:42:55 -0400
committerTom Rondeau <trondeau@vt.edu>2012-06-11 15:42:55 -0400
commita87c609beb6aef9b584c7ff638cdffe7e3637e97 (patch)
tree2f9175f2f3832a9a2eb28fc10876472e719a1a9b /gnuradio-core/src/lib
parente2285793a5a9f5195eb77318452fc2aca95878ec (diff)
log: Restructure config file handling for gr-log.
The xml config file is installed into prefix/etc/gnuradio. A new LOG section is added to gnuradio-core.conf that has an item log_file to point to the log file to be used. If the log_file is not found, we can now set the file to "" to use the BasicConfigurator for very simple console logging. This is what will be used during 'make test'. In gr_fir_sysconfig_x86.cc, all std::cerr calls are replaced with gr-log to easily turn them on/off.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc91
-rw-r--r--gnuradio-core/src/lib/runtime/CMakeLists.txt8
-rw-r--r--gnuradio-core/src/lib/runtime/gr_log.cc13
-rw-r--r--gnuradio-core/src/lib/runtime/gr_log.h23
-rw-r--r--gnuradio-core/src/lib/runtime/gr_log_default.xml64
5 files changed, 80 insertions, 119 deletions
diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc
index 97b8106994..4e3598c5d4 100644
--- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc
+++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc
@@ -48,8 +48,8 @@
// #include <gr_fir_sss_mmx.h>
// #include <gr_fir_sss_sse2.h>
-#include <iostream>
-using std::cerr;
+#include <gr_prefs.h>
+#include <gr_log.h>
/*
* ----------------------------------------------------------------
@@ -177,9 +177,13 @@ gr_fir_sysconfig_x86::create_gr_fir_ccf (const std::vector<float> &taps)
{
static bool first = true;
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
+
if (gr_cpu::has_3dnow ()){
if (first){
- cerr << ">>> gr_fir_ccf: using 3DNow!\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccf: using 3DNow!");
first = false;
}
return make_gr_fir_ccf_3dnow (taps);
@@ -187,14 +191,14 @@ gr_fir_sysconfig_x86::create_gr_fir_ccf (const std::vector<float> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_ccf: using SSE\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccf: using SSE");
first = false;
}
return make_gr_fir_ccf_sse (taps);
}
if (first){
- cerr << ">>> gr_fir_ccf: handing off to parent class\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccf: handing off to parent class");
first = false;
}
return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps);
@@ -205,9 +209,13 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps)
{
static bool first = true;
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
+
if (gr_cpu::has_3dnow ()){
if (first){
- cerr << ">>> gr_fir_fcc: using 3DNow!\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fcc: gr_fir_fcc: using 3DNow!");
first = false;
}
return make_gr_fir_fcc_3dnow (taps);
@@ -215,14 +223,14 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_fcc: using SSE\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fcc: gr_fir_fcc: using SSE");
first = false;
}
return make_gr_fir_fcc_sse (taps);
}
if (first){
- cerr << ">>> gr_fir_fcc: handing off to parent class\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fcc: handing off to parent class");
first = false;
}
return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps);
@@ -233,9 +241,13 @@ gr_fir_sysconfig_x86::create_gr_fir_ccc (const std::vector<gr_complex> &taps)
{
static bool first = true;
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
+
if (gr_cpu::has_3dnowext ()){
if (first) {
- cerr << ">>> gr_fir_ccc: using 3DNow!Ext\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccc: using 3DNow!Ext");
first = false;
}
return make_gr_fir_ccc_3dnowext (taps);
@@ -243,7 +255,7 @@ gr_fir_sysconfig_x86::create_gr_fir_ccc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_3dnow ()){
if (first) {
- cerr << ">>> gr_fir_ccc: using 3DNow!\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccc: using 3DNow!");
first = false;
}
return make_gr_fir_ccc_3dnow (taps);
@@ -251,14 +263,14 @@ gr_fir_sysconfig_x86::create_gr_fir_ccc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_ccc: using SSE\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccc: using SSE");
first = false;
}
return make_gr_fir_ccc_sse (taps);
}
if (first){
- cerr << ">>> gr_fir_ccc: handing off to parent class\n";
+ GR_LOG_TRACE(LOG, "gr_fir_ccc: handing off to parent class");
first = false;
}
return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps);
@@ -269,9 +281,13 @@ gr_fir_sysconfig_x86::create_gr_fir_fff (const std::vector<float> &taps)
{
static bool first = true;
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
+
if (gr_cpu::has_3dnow ()){
if (first) {
- cerr << ">>> gr_fir_fff: using 3DNow!\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fff: using 3DNow!");
first = false;
}
return make_gr_fir_fff_3dnow (taps);
@@ -279,14 +295,14 @@ gr_fir_sysconfig_x86::create_gr_fir_fff (const std::vector<float> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_fff: using SSE\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fff: using SSE");
first = false;
}
return make_gr_fir_fff_sse (taps);
}
if (first){
- cerr << ">>> gr_fir_fff: handing off to parent class\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fff: handing off to parent class");
first = false;
}
return gr_fir_sysconfig_generic::create_gr_fir_fff (taps);
@@ -297,9 +313,13 @@ gr_fir_sysconfig_x86::create_gr_fir_fsf (const std::vector<float> &taps)
{
static bool first = true;
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
+
if (gr_cpu::has_3dnow ()){
if (first) {
- cerr << ">>> gr_fir_fsf: using 3DNow!\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fsf: using 3DNow!");
first = false;
}
return make_gr_fir_fsf_3dnow (taps);
@@ -307,14 +327,14 @@ gr_fir_sysconfig_x86::create_gr_fir_fsf (const std::vector<float> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_fsf: using SSE\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fsf: using SSE");
first = false;
}
return make_gr_fir_fsf_sse (taps);
}
if (first){
- cerr << ">>> gr_fir_fsf: handing off to parent class\n";
+ GR_LOG_TRACE(LOG, "gr_fir_fsf: handing off to parent class");
first = false;
}
return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps);
@@ -326,19 +346,30 @@ gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps)
{
// FIXME -- probably want to figure out best answer for Athlon and code
// add code to select it here...
+ static bool first = true;
+
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
if (gr_cpu::has_sse2 ()){
- cerr << ">>> gr_fir_sss: using SSE2\n";
- return make_gr_fir_sss_sse2 (taps);
+ if(first) {
+ GR_LOG_TRACE(LOG, "gr_fir_sss: using SSE2");
+ return make_gr_fir_sss_sse2 (taps);
+ }
}
if (gr_cpu::has_mmx ()){
- cerr << ">>> gr_fir_sss: using MMX\n";
- return make_gr_fir_sss_mmx (taps);
+ if(first) {
+ GR_LOG_TRACE(LOG, "gr_fir_sss: using MMX");
+ return make_gr_fir_sss_mmx (taps);
+ }
}
- cerr << ">>> gr_fir_sss: handing off to parent class\n";
- return gr_fir_sysconfig_generic::create_gr_fir_sss (taps);
+ if(first) {
+ GR_LOG_TRACE(LOG, "gr_fir_sss: handing off to parent class");
+ return gr_fir_sysconfig_generic::create_gr_fir_sss (taps);
+ }
}
#endif
@@ -347,9 +378,13 @@ gr_fir_sysconfig_x86::create_gr_fir_scc (const std::vector<gr_complex> &taps)
{
static bool first = true;
+ std::string log_file = gr_prefs::singleton()->get_string("LOG", "log_config", "");
+ GR_CONFIG_LOGGER(log_file);
+ GR_LOG_GETLOGGER(LOG, "gr_log.gr_fir_sysconfig_x86");
+
if (gr_cpu::has_3dnowext ()){
if (first){
- cerr << ">>> gr_fir_scc: using 3DNow!Ext\n";
+ GR_LOG_TRACE(LOG, "gr_fir_scc: using 3DNow!Ext");
first = false;
}
return make_gr_fir_scc_3dnowext (taps);
@@ -357,7 +392,7 @@ gr_fir_sysconfig_x86::create_gr_fir_scc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_3dnow ()){
if (first){
- cerr << ">>> gr_fir_scc: using 3DNow!\n";
+ GR_LOG_TRACE(LOG, "gr_fir_scc: using 3DNow!");
first = false;
}
return make_gr_fir_scc_3dnow (taps);
@@ -365,14 +400,14 @@ gr_fir_sysconfig_x86::create_gr_fir_scc (const std::vector<gr_complex> &taps)
if (gr_cpu::has_sse ()){
if (first){
- cerr << ">>> gr_fir_scc: using SSE\n";
+ GR_LOG_TRACE(LOG, "gr_fir_scc: using SSE");
first = false;
}
return make_gr_fir_scc_sse (taps);
}
if (first){
- cerr << ">>> gr_fir_scc: handing off to parent class\n";
+ GR_LOG_TRACE(LOG, "gr_fir_scc: handing off to parent class");
first = false;
}
return gr_fir_sysconfig_generic::create_gr_fir_scc (taps);
diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt
index e36e83e84f..b5fde7d03c 100644
--- a/gnuradio-core/src/lib/runtime/CMakeLists.txt
+++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt
@@ -165,11 +165,3 @@ install(FILES
)
endif(ENABLE_PYTHON)
-
-if(ENABLE_GR_LOG)
-install(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_log_default.xml
- DESTINATION ${GR_PKG_DATA_DIR}
- COMPONENT "core_runtime"
-)
-endif(ENABLE_GR_LOG)
diff --git a/gnuradio-core/src/lib/runtime/gr_log.cc b/gnuradio-core/src/lib/runtime/gr_log.cc
index 5478bd70c0..7af55b155c 100644
--- a/gnuradio-core/src/lib/runtime/gr_log.cc
+++ b/gnuradio-core/src/lib/runtime/gr_log.cc
@@ -39,3 +39,16 @@
#include <gr_log.h>
+void
+logger_load_config(const std::string &config_filename)
+{
+ if(config_filename.size() == 0) {
+ BasicConfigurator::configure();
+ }
+ else if(config_filename.find(".xml") != std::string::npos) {
+ DOMConfigurator::configure(config_filename);
+ }
+ else {
+ PropertyConfigurator::configure(config_filename);
+ }
+}
diff --git a/gnuradio-core/src/lib/runtime/gr_log.h b/gnuradio-core/src/lib/runtime/gr_log.h
index 4f718567df..9050b70eb3 100644
--- a/gnuradio-core/src/lib/runtime/gr_log.h
+++ b/gnuradio-core/src/lib/runtime/gr_log.h
@@ -46,6 +46,7 @@
#include <log4cxx/logger.h>
#include <log4cxx/logmanager.h>
+#include <log4cxx/basicconfigurator.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
@@ -135,16 +136,7 @@ using namespace log4cxx::helpers;
// Load configuration file
-void
-logger_load_config(std::string config_filename)
-{
- if(config_filename.find(".xml") != std::string::npos) {
- DOMConfigurator::configure(config_filename);
- }
- else {
- PropertyConfigurator::configure(config_filename);
- }
-}
+void logger_load_config(const std::string &config_filename="");
/*!
* \brief instantiate (configure) logger.
@@ -179,15 +171,8 @@ class gr_log
static LoggerPtr getLogger(std::string name)
{
- if(LogManager::exists(name)) {
- LoggerPtr logger = Logger::getLogger(name);
- return logger;
- }
- else {
- LoggerPtr logger = Logger::getLogger(name);
- logger->setLevel(log4cxx::Level::getOff());
- return logger;
- }
+ LoggerPtr logger = Logger::getLogger(name);
+ return logger;
};
// Wrappers for logging macros
diff --git a/gnuradio-core/src/lib/runtime/gr_log_default.xml b/gnuradio-core/src/lib/runtime/gr_log_default.xml
deleted file mode 100644
index be721bb021..0000000000
--- a/gnuradio-core/src/lib/runtime/gr_log_default.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- * Copyright 2006,2010,2011 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
--->
-
- <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="RootConsoleAppender" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="Root :%-5p %c{1} - %m%n"/>
- </layout>
- </appender>
-
- <!--Add appender to root to log ALL msgs in one place-->
- <root>
- <priority value="all" />
- </root>
-
- <appender name="errLogRootConsoleAppender" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="errLoggerRoot :%-5p %c{1} - %m%n"/>
- </layout>
- </appender>
-
- <!-- Specify the level for some specific loggers-->
- <category name="gr_log" >
- <priority value ="all" />
- <appender-ref ref="errLogRootConsoleAppender"/>
- </category>
-
- <appender name="errConsoleAppender" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="err :%-5p %c{1} - %m%n"/>
- </layout>
- </appender>
-
- <category name="gr_log_debug" >
- <priority value ="DEBUG" />
- <appender-ref ref="errConsoleAppender"/>
- </category>
-
- </log4j:configuration>
-