From 8426a72bd66850ed1311ee8957dc5b7e4d98e301 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 4 May 2011 12:18:11 -0700 Subject: uhd: moved the logger into the utils subdir --- host/include/uhd/CMakeLists.txt | 1 - host/include/uhd/log.hpp | 91 --------------------------------- host/include/uhd/utils/CMakeLists.txt | 1 + host/include/uhd/utils/log.hpp | 95 +++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 92 deletions(-) delete mode 100644 host/include/uhd/log.hpp create mode 100644 host/include/uhd/utils/log.hpp (limited to 'host/include') diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index dca32089e..74dc4a7d6 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -26,7 +26,6 @@ INSTALL(FILES convert.hpp device.hpp exception.hpp - log.hpp version.hpp wax.hpp DESTINATION ${INCLUDE_DIR}/uhd diff --git a/host/include/uhd/log.hpp b/host/include/uhd/log.hpp deleted file mode 100644 index ff9dfe239..000000000 --- a/host/include/uhd/log.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// -// Copyright 2011 Ettus Research LLC -// -// 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 . -// - -#ifndef INCLUDED_UHD_LOG_HPP -#define INCLUDED_UHD_LOG_HPP - -#include -#include -#include -#include - -/*! - * The UHD logging facility. - * - * The logger enables UHD library code to easily log events into a file. - * Log entries are time-stamped and stored with file, line, and function. - * Each call to the UHD_LOG macros is synchronous and thread-safe. - * - * All log messages with verbosity greater than or equal to the log level - * are recorded into the log file. All other messages are sent to null. - * - * The default log level is "regular", but can be overridden: - * - at compile time by setting the pre-processor define UHD_LOG_LEVEL. - * - at runtime by setting the environment variable UHD_LOG_LEVEL. - * - * UHD_LOG_LEVEL can be the name of a verbosity enum or integer value: - * - Example pre-processor define: -DUHD_LOG_LEVEL=3 - * - Example pre-processor define: -DUHD_LOG_LEVEL=regularly - * - Example environment variable: export UHD_LOG_LEVEL=3 - * - Example environment variable: export UHD_LOG_LEVEL=regularly - */ - -/*! - * A UHD logger macro with default verbosity. - * Usage: UHD_LOG << "the log message" << std::endl; - */ -#define UHD_LOG \ - uhd::_log::log(uhd::_log::regularly, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) - -/*! - * A UHD logger macro with configurable verbosity. - * Usage: UHD_LOGV(very_rarely) << "the log message" << std::endl; - */ -#define UHD_LOGV(verbosity) \ - uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) - -namespace uhd{ namespace _log{ - - //! Verbosity levels for the logger - enum verbosity_t{ - always = 1, - often = 2, - regularly = 3, - rarely = 4, - very_rarely = 5, - }; - - //! Internal logging object (called by UHD_LOG macros) - struct UHD_API log{ - log( - const verbosity_t verbosity, - const std::string &file, - const unsigned int line, - const std::string &function - ); - ~log(void); - - std::ostream &get(void); - - template std::ostream &operator<<(const T &x){ - return get() << x; - } - }; - -}} //namespace uhd::_log - -#endif /* INCLUDED_UHD_LOG_HPP */ diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 71808ac98..6c507dcde 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -23,6 +23,7 @@ INSTALL(FILES byteswap.ipp gain_group.hpp images.hpp + log.hpp pimpl.hpp props.hpp safe_call.hpp diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp new file mode 100644 index 000000000..75c335099 --- /dev/null +++ b/host/include/uhd/utils/log.hpp @@ -0,0 +1,95 @@ +// +// Copyright 2011 Ettus Research LLC +// +// 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 . +// + +#ifndef INCLUDED_UHD_UTILS_LOG_HPP +#define INCLUDED_UHD_UTILS_LOG_HPP + +#include +#include +#include +#include + +/*! + * The UHD logging facility. + * + * The logger enables UHD library code to easily log events into a file. + * Log entries are time-stamped and stored with file, line, and function. + * Each call to the UHD_LOG macros is synchronous and thread-safe. + * + * The log file can be found in the path /uhd.log, + * where is the user or system's temporary directory. + * To override , set the UHD_TEMP_PATH environment variable. + * + * All log messages with verbosity greater than or equal to the log level + * are recorded into the log file. All other messages are sent to null. + * + * The default log level is "regular", but can be overridden: + * - at compile time by setting the pre-processor define UHD_LOG_LEVEL. + * - at runtime by setting the environment variable UHD_LOG_LEVEL. + * + * UHD_LOG_LEVEL can be the name of a verbosity enum or integer value: + * - Example pre-processor define: -DUHD_LOG_LEVEL=3 + * - Example pre-processor define: -DUHD_LOG_LEVEL=regularly + * - Example environment variable: export UHD_LOG_LEVEL=3 + * - Example environment variable: export UHD_LOG_LEVEL=regularly + */ + +/*! + * A UHD logger macro with default verbosity. + * Usage: UHD_LOG << "the log message" << std::endl; + */ +#define UHD_LOG \ + uhd::_log::log(uhd::_log::regularly, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) + +/*! + * A UHD logger macro with configurable verbosity. + * Usage: UHD_LOGV(very_rarely) << "the log message" << std::endl; + */ +#define UHD_LOGV(verbosity) \ + uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) + +namespace uhd{ namespace _log{ + + //! Verbosity levels for the logger + enum verbosity_t{ + always = 1, + often = 2, + regularly = 3, + rarely = 4, + very_rarely = 5, + }; + + //! Internal logging object (called by UHD_LOG macros) + struct UHD_API log{ + log( + const verbosity_t verbosity, + const std::string &file, + const unsigned int line, + const std::string &function + ); + ~log(void); + + std::ostream &get(void); + + template std::ostream &operator<<(const T &x){ + return get() << x; + } + }; + +}} //namespace uhd::_log + +#endif /* INCLUDED_UHD_UTILS_LOG_HPP */ -- cgit v1.2.3