aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2014-09-19 18:22:13 -0700
committerMartin Braun <martin.braun@ettus.com>2014-09-24 17:36:04 -0700
commitfa0313652cc25e17e6c3151f67111fb88c62778e (patch)
tree040ce598775343f3ce94d556191016217fbb2117 /host/include
parenta6070f3492fd8aa5273818bf897b8a0106fe1e88 (diff)
downloaduhd-fa0313652cc25e17e6c3151f67111fb88c62778e.tar.gz
uhd-fa0313652cc25e17e6c3151f67111fb88c62778e.tar.bz2
uhd-fa0313652cc25e17e6c3151f67111fb88c62778e.zip
uhd: Fixed logging bug (#476) -- UHD logging has unexplained effect on packet loss.
- Removed logging from radio_ctrl_core_3000 - Changed logging facility to prevent type conversion when message is not logged
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/utils/log.hpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp
index 1f515c15e..5baa00108 100644
--- a/host/include/uhd/utils/log.hpp
+++ b/host/include/uhd/utils/log.hpp
@@ -21,8 +21,10 @@
#include <uhd/config.hpp>
#include <uhd/utils/pimpl.hpp>
#include <boost/current_function.hpp>
+#include <boost/format.hpp>
#include <ostream>
#include <string>
+#include <sstream>
/*! \file log.hpp
* The UHD logging facility.
@@ -55,7 +57,7 @@
* 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)()
+ uhd::_log::log(uhd::_log::verbosity, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
/*!
* A UHD logger macro with default verbosity.
@@ -78,7 +80,7 @@ namespace uhd{ namespace _log{
};
//! Internal logging object (called by UHD_LOG macros)
- class UHD_API log{
+ class UHD_API log {
public:
log(
const verbosity_t verbosity,
@@ -86,10 +88,29 @@ namespace uhd{ namespace _log{
const unsigned int line,
const std::string &function
);
+
~log(void);
- std::ostream &operator()(void);
+
+ // Macro for overloading insertion operators to avoid costly
+ // conversion of types if not logging.
+ #define INSERTION_OVERLOAD(x) log& operator<< (x) \
+ { \
+ if(_log_it) _ss << val; \
+ return *this; \
+ }
+
+ // General insertion overload
+ template <typename T>
+ INSERTION_OVERLOAD(T val);
+
+ // Insertion overloads for std::ostream manipulators
+ INSERTION_OVERLOAD(std::ostream& (*val)(std::ostream&));
+ INSERTION_OVERLOAD(std::ios& (*val)(std::ios&));
+ INSERTION_OVERLOAD(std::ios_base& (*val)(std::ios_base&));
+
private:
- UHD_PIMPL_DECL(impl) _impl;
+ std::ostringstream _ss;
+ bool _log_it;
};
}} //namespace uhd::_log