diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ConfigParser.cpp | 6 | ||||
| -rw-r--r-- | src/DabMux.cpp | 7 | ||||
| -rw-r--r-- | src/Log.cpp | 13 | ||||
| -rw-r--r-- | src/Log.h | 17 | 
4 files changed, 20 insertions, 23 deletions
| diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 7219663..f0ab13c 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -218,12 +218,6 @@ void parse_ptree(          ensemble->mode = 0;      } -    /* Enable Logging to syslog conditionally */ -    if (pt_general.get<bool>("syslog", false)) { -        etiLog.register_backend(new LogToSyslog()); // TODO don't leak the LogToSyslog backend -    } - -      /******************** READ ENSEMBLE PARAMETERS *************/      ptree pt_ensemble = pt.get_child("ensemble"); diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 069af48..3870df5 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -3,7 +3,7 @@     2011, 2012 Her Majesty the Queen in Right of Canada (Communications     Research Center Canada) -   Copyright (C) 2016 +   Copyright (C) 2017     Matthias P. Braendli, matthias.braendli@mpb.li      http://www.opendigitalradio.org @@ -235,6 +235,11 @@ int main(int argc, char *argv[])              throw MuxInitException("No configuration file specified");          } +        /* Enable Logging to syslog conditionally */ +        if (pt.get<bool>("general.syslog", false)) { +            etiLog.register_backend(std::make_shared<LogToSyslog>()); +        } +          int mgmtserverport = pt.get<int>("general.managementport",                               pt.get<int>("general.statsserverport", 0) ); diff --git a/src/Log.cpp b/src/Log.cpp index 35f3fae..9a58805 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -3,7 +3,10 @@     Her Majesty the Queen in Right of Canada (Communications Research     Center Canada) -   Copyright (C), 2014, Matthias P. Braendli, matthias.braendli@mpb.li +   Copyright (C) 2017 +   Matthias P. Braendli, matthias.braendli@mpb.li + +    http://www.opendigitalradio.org   */  /*     This file is part of ODR-DabMux. @@ -22,17 +25,13 @@     along with ODR-DabMux.  If not, see <http://www.gnu.org/licenses/>.   */ -#include <list> -#include <stdarg.h> -  #include "Log.h"  Logger etiLog; - -void Logger::register_backend(LogBackend* backend) { +void Logger::register_backend(std::shared_ptr<LogBackend> backend) +{      backends.push_back(backend); -    //log(info, "Registered new logger " + backend->get_name());  } @@ -3,7 +3,10 @@     Her Majesty the Queen in Right of Canada (Communications Research     Center Canada) -   Copyright (C), 2014, Matthias P. Braendli, matthias.braendli@mpb.li +   Copyright (C) 2017 +   Matthias P. Braendli, matthias.braendli@mpb.li + +    http://www.opendigitalradio.org   */  /*     This file is part of ODR-DabMux. @@ -22,8 +25,7 @@     along with ODR-DabMux.  If not, see <http://www.gnu.org/licenses/>.   */ -#ifndef _LOG_H -#define _LOG_H +#pragma once  #ifdef HAVE_CONFIG_H  #   include "config.h" @@ -40,6 +42,7 @@  #include <string>  #include <map>  #include <mutex> +#include <memory>  #define SYSLOG_IDENT "ODR-DabMux"  #define SYSLOG_FACILITY LOG_LOCAL0 @@ -131,9 +134,7 @@ class LogLine;  class Logger {      public: -        Logger() {} - -        void register_backend(LogBackend* backend); +        void register_backend(std::shared_ptr<LogBackend> backend);          /* Log the message to all backends */          void log(log_level_t level, const char* fmt, ...); @@ -145,7 +146,7 @@ class Logger {          LogLine level(log_level_t level);      private: -        std::list<LogBackend*> backends; +        std::list<std::shared_ptr<LogBackend> > backends;          std::mutex m_cerr_mutex;  }; @@ -186,5 +187,3 @@ class LogLine {  }; -#endif - | 
