From 412acb853729023e7f24c9ef11699010ed8dadab Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 3 May 2017 22:21:32 -0700 Subject: log: Split add_logger() out of the main logging header This way, C++11 features are not required to build with UHD headers included. --- host/include/uhd/utils/log.hpp | 14 ------------ host/include/uhd/utils/log_add.hpp | 46 ++++++++++++++++++++++++++++++++++++++ host/lib/utils/log.cpp | 1 + host/tests/log_test.cpp | 1 + 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 host/include/uhd/utils/log_add.hpp diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp index 24c7bc1c6..58b3afed4 100644 --- a/host/include/uhd/utils/log.hpp +++ b/host/include/uhd/utils/log.hpp @@ -153,13 +153,6 @@ namespace uhd { std::string message; }; - /*! Logging function type - * - * Every logging_backend has to define a function with this signature. - * Can be added to the logging core. - */ - typedef std::function log_fn_t ; - /*! Set the global log level * * The global log level gets applied before the specific log level. @@ -188,13 +181,6 @@ namespace uhd { * \throws uhd::key_error if \p logger was not defined */ UHD_API void set_logger_level(const std::string &logger, uhd::log::severity_level level); - - /*! Add logging backend to the log system - * - * \param key Identifies the logging backend in the logging core - * \param logger_fn function which actually logs messages to this backend - */ - UHD_API void add_logger(const std::string &key, log_fn_t logger_fn); } } diff --git a/host/include/uhd/utils/log_add.hpp b/host/include/uhd/utils/log_add.hpp new file mode 100644 index 000000000..99b2e6dfc --- /dev/null +++ b/host/include/uhd/utils/log_add.hpp @@ -0,0 +1,46 @@ +// +// Copyright 2017 Ettus Research (National Instruments Corp.) +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 this program. If not, see . +// + +// Note: Including this file requires C++11 features enabled. + +#ifndef INCLUDED_UHD_UTILS_LOG_ADD_HPP +#define INCLUDED_UHD_UTILS_LOG_ADD_HPP + +#include +#include +#include + +namespace uhd { + namespace log { + + /*! Logging function type + * + * Every logging_backend has to define a function with this signature. + * Can be added to the logging core. + */ + typedef std::function log_fn_t ; + + /*! Add logging backend to the log system + * + * \param key Identifies the logging backend in the logging core + * \param logger_fn function which actually logs messages to this backend + */ + UHD_API void add_logger(const std::string &key, log_fn_t logger_fn); + } +} /* namespace uhd::log */ + +#endif /* INCLUDED_UHD_UTILS_LOG_ADD_HPP */ diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp index bfa012323..e850d1374 100644 --- a/host/lib/utils/log.cpp +++ b/host/lib/utils/log.cpp @@ -16,6 +16,7 @@ // #include +#include #include #include #include diff --git a/host/tests/log_test.cpp b/host/tests/log_test.cpp index c466777fc..b0b17ea84 100644 --- a/host/tests/log_test.cpp +++ b/host/tests/log_test.cpp @@ -17,6 +17,7 @@ #include #include +#include #include BOOST_AUTO_TEST_CASE(test_messages){ -- cgit v1.2.3