diff options
Diffstat (limited to 'gnuradio-runtime/lib/logger.cc')
-rw-r--r-- | gnuradio-runtime/lib/logger.cc | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/gnuradio-runtime/lib/logger.cc b/gnuradio-runtime/lib/logger.cc index 273183d5e0..a7e4a25a40 100644 --- a/gnuradio-runtime/lib/logger.cc +++ b/gnuradio-runtime/lib/logger.cc @@ -1,19 +1,19 @@ /* -*- c++ -*- */ /* * Copyright 2012 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, @@ -21,13 +21,13 @@ */ /******************************************************************************* -* Author: Mark Plett +* Author: Mark Plett * Description: * The gr_log module wraps the log4cpp library for logging in gnuradio. *******************************************************************************/ #ifdef HAVE_CONFIG_H -#include "config.h" +#include "config.h" #endif #include <gnuradio/logger.h> @@ -36,7 +36,7 @@ #ifdef ENABLE_GR_LOG -#ifdef HAVE_LOG4CPP +#ifdef HAVE_LOG4CPP namespace gr { @@ -48,25 +48,25 @@ namespace gr { * watch teh config file for changes. */ - // Getters of logger_config - logger_config& + // Getters of logger_config + logger_config& logger_config::get_instance(void) { static logger_config instance; return instance; } - std::string + std::string logger_config::get_filename() { - logger_config& in=get_instance(); + logger_config& in=get_instance(); return in.filename; } - unsigned int + unsigned int logger_config::get_watch_period() { - logger_config& in=get_instance(); + logger_config& in=get_instance(); return in.watch_period; } @@ -108,7 +108,7 @@ namespace gr { // Stop any file watching thread if(instance.watch_thread!=NULL) stop_watch(); - // Load configuration + // Load configuration //std::cout<<"GNURadio Loading logger configuration:"<<instance.filename<<std::endl; logger_configured = logger_load_config(instance.filename); // Start watch if required @@ -125,15 +125,15 @@ namespace gr { { logger_config& instance = get_instance(); if(instance.watch_thread) { - instance.watch_thread->interrupt(); - instance.watch_thread->join(); + instance.watch_thread->interrupt(); + instance.watch_thread->join(); delete(instance.watch_thread); instance.watch_thread=NULL; } } // Method to reset logger configuration - void + void logger_config::reset_config(void) { logger_config& instance = get_instance(); @@ -151,7 +151,7 @@ namespace gr { /***************** Functions to call log4cpp methods *************************/ - logger_ptr + logger_ptr logger_get_logger(std::string name) { if(log4cpp::Category::exists(name)) { @@ -216,7 +216,7 @@ namespace gr { logger->setPriority(level); } - void + void logger_get_level(logger_ptr logger, std::string &level) { log4cpp::Priority::Value levelPtr = logger->getPriority(); @@ -232,13 +232,13 @@ namespace gr { if(levelPtr == log4cpp::Priority::EMERG) level = "emerg"; } - void + void logger_get_level(logger_ptr logger,log4cpp::Priority::Value level) { level = logger->getPriority(); } - void + void logger_add_console_appender(logger_ptr logger, std::string target, std::string pattern) { log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); @@ -254,11 +254,11 @@ namespace gr { } void - logger_add_file_appender(logger_ptr logger, std::string filename, + logger_add_file_appender(logger_ptr logger, std::string filename, bool append, std::string pattern) { log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); - log4cpp::Appender* app = new + log4cpp::Appender* app = new log4cpp::FileAppender("FileAppender::"+filename, filename); layout->setConversionPattern(pattern); @@ -266,13 +266,13 @@ namespace gr { logger->setAppender(app); } - void + void logger_add_rollingfile_appender(logger_ptr logger, std::string filename, size_t filesize, int bkup_index, bool append, mode_t mode, std::string pattern) { log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); - log4cpp::Appender* app = new + log4cpp::Appender* app = new log4cpp::RollingFileAppender("RollFileAppender::" + filename, filename, filesize, bkup_index, append, mode); layout->setConversionPattern(pattern); @@ -290,7 +290,7 @@ namespace gr { for(;logger!=loggers->end();logger++) { names.push_back((*logger)->getName()); } - return names; + return names; } } /* namespace gr */ @@ -301,7 +301,7 @@ namespace gr { void gr_logger_config(const std::string config_filename, unsigned int watch_period) { - GR_CONFIG_AND_WATCH_LOGGER(config_filename, watch_period); + GR_CONFIG_AND_WATCH_LOGGER(config_filename, watch_period); } std::vector<std::string> @@ -320,4 +320,25 @@ gr_logger_reset_config(void) // Remaining capability provided by gr::logger class in gnuradio/logger.h +#else /* ENABLE_GR_LOGGER */ + +/****** Start Methods to provide Python the capabilities of the macros ********/ +void +gr_logger_config(const std::string config_filename, unsigned int watch_period) +{ + //NOP +} + +std::vector<std::string> +gr_logger_get_logger_names(void) +{ + return std::vector<std::string>(1, ""); +} + +void +gr_logger_reset_config(void) +{ + //NOP +} + #endif /* ENABLE_GR_LOGGER */ |